WordPress plugin to combine and minify enqueued CSS and JavaScript files for SEO (site speed).
Minify and combine all local JavaScript and CSS files as well as inline JavaScript and CSS on the site. Optimize script and style loading in WordPress to increase performance and minimize loading time.
I wrote this plugin, because I tried several plugins promised to minify and combine my resources. Unfortunately non of them did that without JavaScript and/or CSS errors.
Features
- Combine local CSS and Javascript files and inline JavaScript and CSS code
- Minify local CSS and Javascript files and inline JavaScript and CSS code
Description
External CSS and JavaScript files will be ignored.
I think, plugin and theme developers use CDN (or other external soruce) for a reason.
jQuery and jQuery migrate will be also ignored.
Some plugin and theme developers sometimes enqueue they JavaScript and CSS files in the footer and in this case, those scripts are enqueued very late, they can not be catched earlier. If jQuery has processed, could cause depency issues.
Process JavaScript and CSS file automatically if no exist or one of the resource file is modified based on the last modified time.
Convert relatvie url('../..') src-s to absolute in css files.
The plugin has two methods:
- First method work with the enqueued list from WordPress, it can be also done, to process the source code after output buffering, but sometimes plugin and theme developers use a conditional to enqueue resources only on some pages. In this case, the plugin will be run every time on the different page, and that would be more time, what we otherwise gain,
- Second method process the HTML source after WordPress render them and before sent to browser. It will create a separate Css/JS file for each page, make sure, all "in the footer" enqueued scripts are correctly processed. This method uses DomDocument and Output Buffering.
NOTE
Methode 1: The combined JavaScript file will be enqueued in the footer. This could cause depency issues, if some very late enqueued JavaScript file has an earlier JavaScript depency. I think, this is very rear, you could remove the file via exopite-combiner-minifier-skip-wp_scripts
filter. (You could use as array( 'jquery', ... )
)