SlimIt – a little benchmark

by Ruslan Spivak on May 9, 2011

SlimIt is in its infancy yet but it can already minify some stuff out.

Here is a comparison of jsmin and SlimIt minification of jQuery 1.6:

jQuery 1.6 (bytes) jsmin (bytes) SlimIt (bytes)
232,651 133,502 132,538

As you can see SlimIt on this source file performs better reducing jquery-1.6.js by additional 964 bytes.

I have to note though that SlimIt is currently slower than jsmin and there are two contributing factors:
1. SlimIt is a complete source-to-source compiler where you have a parser. a lexer and the parser constructs an AST and then minified code is generated by an AST tree walker.
2. Minifier/tree walker uses += operator when concatenating strings and it hurts performance on large strings and multiple concatenations.
Standard solution is to use list.append() and ”.join() methods because they are faster, but I didn’t bother with the speed for now (that will be the target of next releases) – as they say “Make it work first, then make it faster”.

Due to the nature of the minifier (source-to-source compiler) there are many ways how to improve minification considerably, so stay tuned – next releases will give even more bang for the buck.

UPDATE: Looks like doesn’t work reliably for everyone so here is a direct link to documentation where you’ll find all necessary information with further links: Meanwhile I’ll be looking for a place to host the package’s documentation reliably with domain.

If you enjoyed this post why not subscribe via email or my RSS feed and get the latest updates immediately. You can also follow me on GitHub or Twitter.

{ 2 comments… read them below or add one }

Shawn Wheatley May 10, 2011 at 8:10 AM

Congratulations, that’s impressive! Have you run a test suite against your minified version to make sure that nothing is breaking during the minification process?


Ruslan Spivak May 10, 2011 at 9:08 AM

Hi Shawn,

Thanks. Here is what I tried with minified jQuery.

1. I ran it through JSlint test on nodejs that comes with JQuery and it passed without warnings
2. I used minified jQuery with code from chapter7 of jQuery in Action book (photomatic) in my Firefox 4 and it worked just fine
3. I pretty printed minified output back with SlimIt using to_ecma method and then repeated steps 1 and 2 with pretty printed output and again it worked fine.

It’s by no means an indication that SlimIt is bug free, but I think it’s a good starting point and I continue to add more tests.
And if you try it and find any bugs or you have any suggestions, please, file them on GitHub.



Speak your mind

Previous post:

Next post: