TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Javascript, AJAX, E4X (http://www.talkphp.com/javascript-ajax-e4x/)
-   -   JS Compressor (http://www.talkphp.com/javascript-ajax-e4x/1498-js-compressor.html)

Haris 11-19-2007 01:53 PM

JS Compressor
 
Salathe gave me link to a js compressor but after compressing my JS, it doesn't work.

I tried in different compressors but no use.

How do you compress your js?

Wildhoney 11-20-2007 12:11 AM

All JS compresses do is remove all the white space - it's all they can do. In the long run, if you're creating large Javascript files then Prototype will be able to shave a lot off of the file sizes due to the short-handed ways of writing the code. Such as $() instead of document.getElementById().

If you want to be your own Javascript compressor then once you're done, please all your Javascript on one huge line - of course keep another version that is formatted in a drop dead gorgeous way so that you can easily edit it. The good thing about Javascript is that it doesn't need the semi-colons at the end of each line, unlike PHP, and so removing those for each line will save you countless bytes!

Sam Granger 11-20-2007 12:13 AM

As mentioned through msn, try http://compressor.core.pathfinder.gr/

Hope it worked for you.

Salathe 11-20-2007 01:32 AM

I linked Haris through to the widely used Packer (from Dean Edwards). If your JavaScript didn't work after being 'packed' chances are there's some non-standard thing in your code which the packer trips up on -- semi-colons being the usual culprit (they're essential since packed code is all on one line).

Wildhoney mentioned using Prototype to cut down on the amount of code that you have to write. Remember that you can compress Prototype down as well, and if you're using more modular libraries/frameworks (Mootools is a good example) then it really makes sense to only ever include the parts of the libraries/frameworks that you're going to be using (if that's possible).

Other popular compression tools include YUI Compressor, Douglas Crockford's JSMin and Dojo ShrinkSafe. I don't know if any of those have a web interface to copy/paste code from/into.

Haris 12-08-2007 10:47 AM

I had to improve my syntax to compress the javascript with those tools.

dean.edwards packer worked flawlessly. :-)


All times are GMT. The time now is 10:58 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0