Jul
8
2014

MagicMin Version 3 Available!

Minifying CSS and Javascript just got way more awesome with MagicMin 3.0.0!

Along with better directory path support for windows machines, V3 includes the ability to output merged/minified files with unique hashed filenames for better caching support decreases your performance rating).

Unique generated filenames are also considerably more reliable when it comes to ensuring your visitors always have the most current content, as each time a new minified or merged file is generated- so is a new filename for the file!

require_once( 'class.magic-min.php' );
//Use google closure API, gzip the resulting file, and hash filenames
$minified = new Minifier( 
    array(
        'gzip' => true, 
        'closure' => true, 
        'hashed_filenames' => true
    )
);

So whereas previously, your source code would’ve looked something like…

<link rel='stylesheet' href='http://yoursite.com/styles.css?v=1.2.1' type='text/css'  />

Now they’ll look like…

<link rel='stylesheet' href='http://yoursite.com/d268f0e1f49d63aa24d87004673ec6e05855deb1.css' type='text/css' />

And (if and) when the minified file is regenerated to merge in changes, the filename will be freshly generated and would be something similar to…

<link rel='stylesheet' href='http://yoursite.com/c195919e63da89bba8bc7d80df64873609681732.css' type='text/css' />

Backward compatibility

100%. If you’ve already been using MagicMin, the updates will never break what you already have (because I use it too!)

[dm]18[/dm]

2 Comments + Add Comment

  • Hi Bennett,
    Does the Magic min support chinese in JS file?
    Because I try to min the JS with chinese character, then the min file is empty.
    (function( window, undefined ) {
    “use strict”;
    var
    // constructor
    _t = function(){},// public
    // private variable
    _p = {
    menu: {
    line1: ‘關於’,
    line2: ‘Press’,
    line3: ‘加入我們’,
    line4: ‘私隱及條款’,
    line5: ‘English’
    },

    //this is assign to gobal variable
    window.StringText = _t;

    })( window );

    /////// Output
    /**
    * Filename: Strings.js
    * Generated by MagicMin 2014-08-28 at 06:30:19 AM
    */

    • That’s a very good question. Are you using the default google closure? And/or is the character encoding of your JS file UTF-8?

Leave a comment