Keeping Your JavaScript Small

As you know that with websites speed is very important. Unfortunately many good JavaScript libraries are rather large (many are over 40K). Even with many people having high speed internet connections you should still try to keep your application under 50K (including the design). This is one reason that some tools ,such as General Interface, have only been adopted in the enterprise as people are guaranteed to have a faster connection.

One of the things that can make a huge difference in JavaScript size is to remove white space. I personally use MemTronic's FREEWARE HTML/JavaScript Cruncher-Compressor (click here to go to the application). The tool has various levels of compression and can make your JavaScript pretty small and even obfuscate your code (of course don't delete your original code or it will be hard to edit). I've seen code reduced by up to 70% using the tool, which keeps more complex applications loading quickly.

memtronicpic.jpg

Try using the tool with your favorite JavaScript code and run some load tests, you'll probably even be able to notice the difference of load time. If you reduce your code, I'd love to hear how much smaller your code gets, so leave a comment of your results.

I'd just like to suggest that there is also another tool that works really well for compressing both JavaScript and CSS. It's free, open source and works really really well: http://www.julienlecomte.net/yuicompressor/

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <div> <blockquote> <object> <embed> <img> <param>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.