Create shared CSS and JavaScript files
Managed site files hold shared CSS or JavaScript for one website. Their drafts and live versions have their own lifecycle. Saving a file updates its draft; review the version used by a page publication before expecting anonymous visitors to receive it.
Before you start
Section titled “Before you start”- Use design permission and a sample page that references the file. Record the previous live version for recovery.
-
Create or open the managed code file from Files or Explorer Code. Set its name and order deliberately. Keep unrelated experiments in separate files so publication impact is easier to review.
-
For JavaScript, choose Head or Body end and Module or Classic. Ensure the script runs after the DOM it uses, and avoid including a library twice through both head markup and a site file.
-
For CSS, review Subset CSS on page publish. If enabled, add a class safelist for classes introduced dynamically by scripts or external content. Test those states; a class absent from static markup can otherwise lose its rules.
-
Choose Save file, preview the page and then review publication dependencies. Draft CSS is visible in Design; scripts run in Preview JS and publicly. Verify the resulting public asset URL after publishing.
Check the result
Section titled “Check the result”- The public page references the intended immutable file version and its shared behavior works across representative pages.
Troubleshooting
Section titled “Troubleshooting”If a saved change is missing publicly, inspect the live version and page dependency list. If only dynamic styles are missing, check subsetting and safelist before disabling optimization for the entire site.
Related guides
Section titled “Related guides”- Recover file edits and resolve conflicts
- Preview behavior and diagnose script errors
- Save, preview, publish and schedule
Applies to Strukt c02552848c92 · 2026-10-31