Once CDN is enabled, the Code minification settings will be available. Minification removes unnecessary characters like comments and whitespace from your code.
These characters are great for humans when we’re editing code, but browsers do not need them. Removing them optimizes your code, reduces page size, and reduces page load time.
Enable Code Minification
Click on the Settings button to configure your preferred code minification settings.
In the Code minification pop-up modal that appears, choose CSS, JS, or both, and click the Change Settings button to save your settings.
- Be sure to check your site after enabling Code minification. Some browsers may have issues with minified items. If you see any problems on your site, disable Code minification.
- Enabling code minification may take a few minutes to take effect.
- If you have your own Cloudflare account, you’ll need to clear cache at Cloudflare (either in the Cloudflare dashboard or the Cloudflare plugin) for minification to work.
- Any files ending in .css or .js served over the Kinsta-hosted domain will be minified, depending on which file type you enable minification for or if you enable it for both. For instance, if you host example.com with us and choose to minify CSS files, both
example.com/wp-content/plugins/woocommerce/some-file.csswill be minified, but externally linked assets like
twitter.com/styles/example-shared.csscan’t be minified by this tool.
Check for Code Minification
- Visit your site and open developer tools in your browser.
- On the Network tab, double-click a JS or CSS file to open it in a new tab. Be sure to choose one that wasn’t previously minified by your theme or a plugin.
- Check the file for white space or comments. If you’re seeing any JS or CSS files that aren’t minified, clear the CDN cache and reload the page a couple of times, then check the JS or CSS files again.
- If files aren’t minified after clearing the CDN cache, open a new chat with our Support team and let them know the URLs of the files that aren’t minified.
CDN Code Minification Advantages
This minification is done on Cloudflare’s edge and cached there too, so it has some advantages over code minification with a plugin:
- Your server doesn’t have to use resources (CPU/memory/storage) to minify the files. Cloudflare handles that on their side.
- Your server doesn’t have to subsequently serve the minified files, either. Cloudflare serves them directly from the closest edge server to the visitor making the request.
- Cloudflare minifies the files in the background, so the first request to a not-yet-minified asset is not delayed by Cloudflare’s process to make it minified. The next request to that asset should get the cached, minified version.