Magento Minifier

February 4th, 2015

Magento Minifier parses all javascript & css files included on a page and removes all unnecessary characters. The most simple step is to remove spaces, tabs and new lines – but there’s more than just that. Of course, for small files compression is insignificant, but when you work with almost 600KB and around 30 requests, you can save a lot. Here’s a quick example on an old Magento installation:

Initially
26 JS requests, 479 KB + 4 CSS requests, 102 KB

With Magento’s default merging enabled
1 JS request, 360 KB + 1 CSS request, 108.2 KB
Already saved 28 requests, which means less overhead.

With the Magento Minifier enabled
JS is 255 KB, which means almost 47% compression
CSS is 92 KB, which means almost 10% compression

 

Advantages

  • Faster loading times
  • Less stress on the server and on bandwidth
  • Improving PageSpeed score with 4-8 points
  • Checking 4 to-do’s from the Web Performance Best Practices Guide
  • Browser & reverse proxy cache invalidation through automatic filename changes – works great with CloudFront and Varnish
  • Layout handle merging algorithm, so common resources get cached on the client-side

 

Credits

This plugin wouldn’t exist if it weren’t for these two outstanding PHP projects:
Joe Scylla’s CssMin
Ryan Grove’s JsMin
Big thanks to both of them.

Many thanks to Gordon Lesti and Fishpig, for the idea behind layout-handle merging. (the initial problem & solution explained by Fishpig).

 

Install & Config

Manual install

Modman

  • modman clone https://github.com/firewizard/Mandagreen_Minifier.git

Composer

 

  • Clear Magento’s cache
  • Log out from the admin if you’re already logged in, then log back in.
  • Go to Configuration > Developer and configure the module. CSS and JS merging is required for this plugin to work

 

Compatibility

This extension has been tested with all Magento CE versions 1.4 through 1.9.

 

Known Caveats

  • Enabling layout-handle merging can lead to js/css files being loaded in a different order than expected (leading to strange bugs, especially for js merging).
  • Files added from PHP won’t be grouped properly, creating additional requests.
  • When using full page caching, a full cache refresh is required anytime a js or css file is changed. This should be fixed in future version.

 

Support

If you have any issues with this extension, open an issue on GitHub.

 

Contribution

Any contribution is highly appreciated. The best way to contribute code is to open a pull request on GitHub.

 

License

GNU General Public License, version 3 (GPL-3.0)

 
Always test your store before putting this extension in production

  1. No comments yet.
  1. No trackbacks yet.