Free software jsmin in python

Some people in the web programming arena or packaging arena may be aware of the technique called minification for making JavaScript files smaller so that they transfer to client browsers quicker. One of the simpler scripts for minifying JavaScript is known as jsmin.js by Douglas Crockford. Unfortunately, this script is licensed under a non-free software license (the license contains a use restriction in that it “shall be used for Good, not Evil.”.) which has caused a bit of pain to Linux distributions which care about shipping only free software in their repositories.

Just recently, the following tool from Google’s v8 project was pointed out to me: jsmin.py. This implementation does not carry the problematic license. Instead it’s under the New BSD license like the rest of v8. This is exciting as there’s now the potential for people to port their projects from the non-free code to this implementation which makes life easier for free software developers.

Advertisements

5 thoughts on “Free software jsmin in python

  1. At a quick glance, it seems different to the one used by OpenLayers:
    http://trac.osgeo.org/openlayers/browser/trunk/openlayers/tools/jsmin.py

    This one was judged unacceptable in Fedora since it appears to be a rewrite in Python of the original jsmin tool in which the author of the Python script simply looked at the C code and translated it to Python:
    http://www.redhat.com/archives/fedora-legal-list/2009-August/msg00000.html

    If the one from V8 is really a clean room implementation, that’s very interesting indeed!

  2. This tool will hopefully be in Fedora shortly, the package is being reviewed.

    It should be noted, though, that it’s not as good as the jsmin original right now : it can apparently mangle valid code.

  3. I don’t care a bit about jsmin, but do you know whether there is free (as in Debian/OSI/FSF-compliant free) version of jslint? Also if it was maintained to follow the latest developments/fads in Javascript (e.g., jslint hates const and let). Lazyweb, will you help me?

    • Thanks! I didn’t know about the Perl module!

      yui-compressor does both a better job of compressing and is a lot more complex. Unlike the perl and python solutions, yui-compressor is built on top of the rhino library (a java library for executing javascript). by design, it knows a lot more about the JavaScript code that it’s working on than jsmin and similar minifiers but it also takes a lot more work to get it to build and run. In fact, I haven’t been able to get yui-compressor to build with the Fedora version of rhino and openjdk. 😦 A similar program is Dojo’s shrinksafe and at least in Fedora-13, I’ve been able to get that to build and run against Fedora’s rhino.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s