Minifying code for PhoneGap App?

Well tickle my feet and call me grandma, but I have been minifying the javascript for my phoneGap app, and it most certainly improves performance.

Of course there is barely any difference in terms of the size of the application package. So the one time that a user downloads and installs the app, there is no real gain from minifying.

But every time the user runs the app, having minified javascript does make a difference. Even though the file is local, it still needs to be loaded into the 'browser', and smaller files are loaded faster and will thus start executing earlier.

And chances are you'll have a lot of javascript since most apps want to "do" something instead of just providing passive HTML content.

I'm considering minifying the phonegap.js file itself too. Any thoughts on that are highly appreciated.


In general it is not worth minifying PhoneGap application. Minifying is beneficial for web application as it reduces size of each request.

With PhoneGap all your HTML/JS/CSS will be bundled into application package (which is compressed btw.) and downloaded once on application install. So there won't be any gains in speed.


An answer from PhoneGap representative, copied from PhoneGap Community Forum :

"Not necessarily. JavaScript compression is most important for network performance - web applications that are requesting files from remote servers need to wait for the file to be downloaded, so having a smaller file makes the process a lot smoother.

What matters on mobile devices, and PhoneGap apps specifically, is memory, rather than network traffic. While you may get some memory benefits from running a minified JS file, both the original and the minified file are interpreted into the same code*, so the difference is negligible.

In most cases, minifying JavaScript is low on the list of priorities for a PhoneGap application."