Jump to content

Recommended Posts

  • Moderators

There have been some passing references to Googles Closure Compiler in this forum

http://forums.smartmobilestudio.com/index.php?/topic/4097-sms-lose-weight/?hl=closure&do=findComment&comment=17630

http://forums.smartmobilestudio.com/index.php?/topic/3970-secure-obfuscation-for-urls/?hl=closure&do=findComment&comment=17051

 

This amazing compiler does the following

 

 

 

The Closure Compiler is a tool for making JavaScript download and run faster. 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.

 

 

So a new visual project with a simple button compiles to a main.js file of 266 kB uncompressed

Pushing this file through the Closure compiler reduces the filesize to 53 kB, which is a 80% saving

Not bad

 

Compiler output :

 

Original Size: 40.84KB gzipped (258.59KB uncompressed)

Compiled Size: 14.58KB gzipped (51.93KB uncompressed)

Saved 64.31% off the gzipped size (79.92% without gzip)

 

I did this on a couple of projects and AFAICS the re-compiled code works as expected

 

 

Optionally this compiler can be used as part of a build process, or even built right into the IDE

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...