(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.






October 15th, 2005 at 3:46 pm
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
October 17th, 2005 at 2:51 am
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.
October 18th, 2005 at 12:41 pm
No problem. I’ll shoot him an email and hopefully we can nip a wild number like that in the bud.
June 18th, 2006 at 1:42 am
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.
July 27th, 2006 at 4:56 pm
[…] 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: […]
November 29th, 2008 at 5:49 pm
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;
}
}