Save dynamic CSS/JavaScript as static files

When CSS and JavaScript code is loaded by a PHP file, the file is generated dynamically on each page load. This can take a long time and slow down your site. 

WP Rocket has an automatically-enabled feature (that means there's no checkbox in the settings for it) to convert those files to static CSS and JavaScript files which will be loaded much faster. A static file is one that only has to be generated once, then can be served directly.

How does it work?

WP Rocket will detect files with a .php extension that are enqueued using the wp_enqueue_script and wp_enqueue_style functions.

Since these functions occur before caching, this optimization will also be applied when bypassing WP Rocket.

The content of the PHP file(s) will be saved into a static .js or .css file in the cache/busting folder.

Does your site use dynamic CSS or JavaScript?

If your site uses these kinds of files, you can identify them in a couple of different ways. 

1. In the source code of your page these files will have the .php extension and when you click on them the content will be either CSS or JavaScript code.

2. You can also identify them in the Network tab of your browser, or in the waterfall chart of a speed testing tool (GT Metrix, Pingdom etc). Look for files with the .php extension and a content type of  either CSS or JavaScript:

Resolving issues

If this feature causes a problem on your site you can disable it with the helper plugin found here.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.