How to minify a js file direct in Sublime Text 2

Compressed javascript files are ideal for production environments since they typically reduce the size of the file by 30-90%. Most of the filesize reduction is achieved by removing comments and extra whitespace characters that are not needed by web browsers or visitors.

I just found this plugin for Sublime Text 2:
(The plugin minifies JavaScript by using the Google Closure Compiler.)

Manual installation

To install any plug in in Mac OS X version:

  1. Click Sublime Text 2 menu.
  2. Click Preferences, Browse Packages.
  3. Copy the Plugin folder inside Packages folder.
  4. Restart Sublime Text 2

That's it, now you can use command:

 [control] + [alt] + m 

To minify your js file.

Using Package Control for installation

Another way to install the plugin is via the Package Control of Sublime Text 2 which is an utility to do manage plugins/packages easily.

  1. Install Package Control if you have it yet.
  2. Use following keys to throw the Package Control: [command] + [shift] + p
  3. Select Package Control: Install Package (figure 1)
  4. A new window will appear, now, if you type "JsMin", you will see information about the JsMinifier plugin (figure 2).
  5. Press <enter> or click on that plugin and the installation will start.

  6. Wait for finalization and that's it!

Figure 1. Package Control: Install Package

Figure 2. Select JsMinifier

About the author

Enterprise Web Developer

Julio Mora is an experienced developer who has worked creating mobile applications for the demanding video game industry. He has experience working with international teams and has earned the respect of his team members for his commitment to delivering excellent work products. He continues to focus on building an exceptional user experience. His background includes:

  • Web Technologies: Content Management Systems (IBM WCM), JavaScript libraries (jQuery, Dojo), CSS3, HTML5, mobile web, Operating Systems.
  • Research: Artificial Intelligence, Computer Graphics and Computer Simulation for robotics.
  • Mobile Technologies : IOS Development, Android Development.