jump to navigation

Minify JavaScript in Eclipse-PDT with Google Closure Compiler December 14, 2011

Posted by Tournas Dimitrios in JQuery.

A good practice is to  start minifying your jQuery scripts before deploying them to decrease download time . There are different tools available to archieve this goal , web-based — command-line-based and Gui’s . I found Google Closure Compiler, which not only minifies , it also obfuscates and even optimizes your scripts (dead code removal etc)! The Closure Compiler is a tool for making JavaScript download and run faster. It is a true compiler for JavaScript . Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript . It parses your JavaScript , analyzes it , removes dead code and rewrites and minimizes what’s left . It also checks syntax , variable references , and types , and warns about common JavaScript pitfalls .
The best place to get this done is within Eclipse , and you can do it using a plugin by Rock Star Apps . Details here: http://update.rockstarapps.com/index.html . Installing the plugin is “dead-simple” as you would any other plugin in Eclipse .

Follow these steps to install the  plugin on Helios . The process is similar on  Older/newer versions of PDT .
My version is : Helios Release   Build id: 20100617-1415 .

  • Go to the [Help ->Install new Software ] Menu Item .
  • Click on “Add” new tab .
  • Give a Unique name (this is for your Reference only )
  • Define the URL :  http://update.rockstarapps.com . Follow the  process by accepting the installation .
  • PDT will restart automaticaly .
  • You should now be able to right click a Javascript file and go Rockstarapps > Compress and you get loads of options like Google Closure Compiler , YUI Compressor etc . You can even tell it to auto-build . When you are on the options screen , select “Automatically recreate file when one of it’s dependencies changes”, and then it will rebuild every time you save the source file .
  • Happy Coding🙂


No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s