[make-the-web-faster:262] CSS Minifier performance issues

5 views
Skip to first unread message

Billy Hoffman

unread,
May 6, 2010, 1:00:20 PM5/6/10
to Make the Web Faster
Been bumping into a problems with tools that do CSS minification.

The first is that most css minifiers use regexs to find and fix
bloated CSS. This was the approach taken by cssmin and YUI Compressor
and nearly all other tools out there seem to just be ports or slight
modifications to YUI's logic. Unfortunately these regexs are pretty
slow, especially the empty rule regex. The problem gets worse the
larger the CSS file is and performance techniques like combining CSS
files and embedding background images as data URIs makes for some huge
CSS.

The first problem led me to the second: I went looking for a css
minifier that didn't use regexs and I learned that not all CSS
minifiers do the same thing. The new C++ implementation the CSS
minifier in Google's Page Speed, for example, is just a port of
JSMin's logic. It removes comments, and whitespace. Now don't get me
wrong, it is super fast. Only one pass through the character array
until YUI's 12 or so. But its not a very comprehensive minifier.
That's it. Even the various ports of YUI Compressor's logic are
different. They don't have all of the regexs, etc. So its almost
impossible to know what someone means when they say "css minification"
because there is no standard.

Anyone know of a CSS minifier that is fast *and* comprehensive?

Thanks,
Billy
--
Check your Website's Performance Now:
http://zoompf.com/free



--
You received this message because you are subscribed to the Google Groups "Make the Web Faster" group.
To post to this group, send email to make-the-...@googlegroups.com.
To unsubscribe from this group, send email to make-the-web-fa...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/make-the-web-faster?hl=en.

Den Golotyuk

unread,
Jun 2, 2010, 4:20:54 AM6/2/10
to Make the Web Faster
You should better cache the results of minifying you css and js.
This is a one-time process during deployment, so why waste processor
capacity in production.

Billy Hoffman

unread,
Jun 2, 2010, 11:34:43 AM6/2/10
to make-the-web-faster
I 100% agree. These PHP-based combiner and minifiers annoy me. Hitting the app tier is a 10x performance hit over serving a static file. Even hitting a PHP files that checks to see if it can serve an already minifier/combined static file is a 10x hit. These optimizations should not be done at runtime on the production environment. We wrote about it here:

http://zoompf.com/blog/2009/12/the-challenge-of-dynamically-generating-static-content

Billy
-- 
Billy Hoffman
Founder and CEO,
Zoompf - Web Performance Scanning
Reply all
Reply to author
Forward
0 new messages