0

How to minify-compress-aggregate (AMC) static and dynamic resources (especially CSS&Js) in Wordpress?

I need a way to do the three in Wordpress.

I don't need a caching mechanism, I need only AMC to serve these resources faster in the first place.

I have no plans for using a CDN, at the moment.

I emphasis that I need all 3 virtues: Aggregate, minify and compress. A solution that doesn't give all three is not something I seek here.

0

Here is a plugin that does all 3 actions : https://wordpress.org/plugins/merge-minify-refresh/

Plugin Description :

This plugin merges/concatenates Cascading Style Sheets & Javascript files into groups. It then minifies the generated files using Minify (for CSS) and Google Closure (for JS – fallback to Minify when not available). Minification is done via WP-Cron so that it doesn’t slow down the website. When JS or CSS changes files are re-processed. No need to empty cache!

Version 1.7.0 added the ability to generate .css.gz & .js.gz files. Your webserver may need to be configured to use these files. Here is how to use these files in Apache:

#Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]

#Serve gzip compressed JS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]

#Serve correct content types, and prevent mod_deflate double gzip.
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1,E=is_gzip:1]
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=is_gzip:1]
Header set Content-Encoding "gzip" env=is_gzip

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.