One of the big changes in Autoptimize 2.0 (estimated released between Christmas & New Year) is a significant improvement in the minification speed (30% faster should be no exception). As a quick reminder, this is what Autoptimize did until now;
- extract code from HTML & remove original references
- aggregate all code into one string
- check if a minified version of that string exists in cache
- if not in cache;
- minify that string
- store the result in cache
- inject reference to cached autoptimized code in HTML
It is the actual minification in step (4) which can slow Autoptimize down (hence the importance of making sure your cached files are reusable). In Autoptimize 2.0 above logic was changed to improve performance;
- extract code from HTML & remove original references
- aggregate all unminified code into one string, but only put a reference to already minified files (*min.css and *min.js)
- check if a minified version of that string exists in cache
- if not in cache;
- minify that string
- replace references to minified files with (slightly optimized) contents
- store the result in cache
- inject reference to cached autoptimized code in HTML
As the to-be-minified string is smaller, the JS- & CSS-minifiers have less code to optimize, indeed speeding up the process significantly. Additionally this also reduces the chances of problems with the re-minification of already minified code (e.g. p. So nothing but advantages, right?
Now this was tested rather thoroughly and all known kinks have been ironed out, but If this “injected minified code late”-approach does not work in your context, you can simply disable it by hooking into the API and setting the autoptimize_filter_js_inject_min_late and/ or autoptimize_filter_css_inject_min_late filters to false (use code snippets rather then adding it to your functions.php);
add_filter('autoptimize_filter_js_inject_min_late','no_late_inject');
add_filter('autoptimize_filter_css_inject_min_late','no_late_inject');
function no_late_inject() {
return false;
}