Blog Post RSS ?

Blogs » JavaScript & CSS » Free JavaScript compressor available online
 

Free JavaScript compressor available online

by Kevin Yank

(Via Ajaxian) The Dojo Toolkit is one of the biggest JavaScript libraries out there, weighing in at about 4MBover 250KB of JavaScript code as written. That’s why the makers of the toolkit developed a JavaScript compressor to reduce the library to a reasonable size for use on real-world Websites. This compressor has the advantage over several others out there that it actually parses the JavaScript code it is compressing–using the Mozilla Rhino JavaScript parser–rather than simply relying on a set of regular expressions to make a best guess as to what parts of the code may be compressed safely.

Now that same compressor is available online through a convenient Web form, called ShrinkSafe. It lets you upload one or more JavaScript files, and it will give you back a single, compressed JavaScript file for you to use on your site.

This post has 6 responses so far

  1. If we’ve got 4 meg of JS code, I’ll eat my (infrequently worn) hat. Before “compression”, our kitchen-sink build weighs in at 260K, and most builds we ship are eventually

     
  2. Alex, sorry about that. The 4MB figure was taken from Tim Lucas’s presentation on AJAX at Web Essentials 2005 a few weeks ago. Perhaps he was being facetious, but the 4MB figure seemed oddly specific, so I took him at his word.

     
  3. No problem. I’ll shoot him an email and hopefully we can nip a wild number like that in the bud.

     
  4. Hi, I also found the ShrinkSafe compressor useful. If you use it in combination with Dean Edwards compressor engine the result is even smaller js files.

    I did exactly so with the Prototype library. You can use the javascript compressor at javascriptcompressor.com and also download the compressed prototype library - its only 21KB compared to its original 49KB.

     
  5. […] As I’ve covered before, compressing JavaScript can be a tricky problem to solve. There are a lot of tools out there that are utter crap. But here are a few that work fairly well: […]

     
  6. script language=”JavaScript”>
    function fn_validateNumeric(thi,dec)
    {
    if (((event.keyCode 57)) && (event.keyCode != 46))
    event.returnValue = false;
    if(dec==”n” && event.keyCode == 46)
    {
    event.returnValue = false;
    }
    else
    {
    if(event.keyCode == 46 && instr(thi.value,”.”)>=0)
    event.returnValue = false;
    }
    }

     

Sponsored Links

Leave a response

You are not logged in, log in with your SitePoint Forum username and password.

-OR- Post Anonymously

* Make sure any code samples are escaped (i.e. ‘<b>’ becomes ‘&lt;b&gt;’).

If not logged in, your comments will be placed in a moderation queue. This means your comment may not appear until one of our moderators approves it.

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.