Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Removing inline scripts and styles

Move a maintained theme toward a strict Content Security Policy - find inline script blocks, event handler attributes, javascript: links and style attributes, move them into files and data attributes - following how the…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/lifecycle/removing-inline-scripts-and-styles.md

On this page

Removing inline scripts and styles

This page is for designers maintaining a theme written before Content Security Policies were common. The how-to of CSP-safe templates is in CSP-safe design, No inline JavaScript and No inline CSS; this page is the migration routine.

Why now

Exponential sends a Content Security Policy from site.ini [ContentSecurityPolicy]: report-only on the administration by default and off on sites, with script-src 'self' and style-src 'self' (Content Security Policy). A site owner who switches it on for their site needs a theme without inline code.

The 7x themes did this migration in their releases of 17 October 2026: cjw_themes_jumper v0.1.6 ("the starter design without inline scripts"), sevenx_themes_simple v1.0.24 and sevenx_themes_media v1.5.70.

Step by step

  1. Find inline code:

    grep -rn -E "<script[^>]*>[^<]|on(click|change|load|submit)=|javascript:|style=\"" extension/mytheme/design
  2. Move scripts into files in design/mytheme/javascript/ and load them through the design's script list.

  3. Replace event attributes and javascript: links with href="#" or buttons plus data-* attributes that a script file reads, as cjw_themes_jumper 0.1.6 did with data-cjw-bubble.

  4. Pass values from templates in data-* attributes instead of writing them into script blocks.

  5. Replace style="" with classes in the stylesheet; per-element values go into data-* attributes or custom properties set from a class.

  6. Test with the policy in report-only mode on a test siteaccess (Mode=report-only) and read the browser console: no reports.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x