25% off ProSNIPC25OFF

Asset files: externalize & minify

Serve your CSS and JavaScript snippets as cached external files instead of inline markup (and optionally minify them) so browsers can cache the output and pages load faster.

Pro

Asset file externalization and minification are SnipCraft Pro features. Both settings are locked in the free edition.

Externalizing assets

When Serve CSS & JS snippets as cached files is enabled, SnipCraft combines all enabled, unconditional CSS snippets into a single .css file and all enabled, unconditional JavaScript snippets into a single .js file. These files are written to wp-content/uploads/snipcraft/ and enqueued with WordPress's standard asset API, so browsers receive a proper cacheable URL rather than an inline <style> or <script> tag.

A snippet is eligible for externalization only when it has no run-when conditions attached and no explicit head or footer placement override. Conditional snippets stay inline because their output can vary per request. A static cached file cannot carry that per-request logic safely. The same applies to snippets with an explicit placement: they are left in their designated position as inline tags.

Cache invalidation is content-based: the filename includes a SHA-1 hash of the combined output, so the URL changes automatically whenever any snippet in the bundle changes. Stale files from the previous hash are pruned from the uploads directory at that point, keeping the folder tidy. If a file cannot be written for any reason, SnipCraft falls back to inline output. The feature is fail-open and never breaks the page.

Minification

Enable Minify the combined CSS & JS files to strip whitespace and comments from the generated files before they are written to disk. This reduces the download size of the bundles for visitors. Minification only applies when externalization is turned on. The setting has no effect on its own.

When to use it

Externalization is most beneficial on high-traffic sites that have several always-on CSS or JavaScript snippets, anywhere inline tags add up across many page views. Enabling it lets those assets be served from the browser cache on repeat visits. Sites with few snippets, or snippets that are mostly conditional, will see little difference, since conditional snippets remain inline regardless of the setting.

Performance settings: serve CSS & JS snippets as cached external files, then optionally minify the combined output.

For the snippet types that can be externalized, see snippet types. To unlock this and all other Pro features, see SnipCraft Pro.