siva636
siva636

Reputation: 16441

How to Gzip a javascript file?

179KB of jQuery is Minified and Gzipped to 26KB. I am trying to do the same compressions to my javascript files and found the Yuicompressor to Minify it. But I am still searching for a way to Gzip it.

How can I Gzip my Javascript files?

Upvotes: 17

Views: 31841

Answers (3)

Yann Ramin
Yann Ramin

Reputation: 33167

You would use gzip, the GNU compression utility. Luckily, the gzip algorithm and file structure is implemented by numerous other tools, such as 7zip (for Windows). You can configure your server (via mod_deflate or others) to compress files on the fly, but for static content its a waste of CPU power.

Here is an article which shows how to transparently serve pre-compressed gzip to browsers which support it: https://typeoverflow.com/typeoverflow/serve-pre-compressed-gzip-javascript-to-browsers-4k6j

Upvotes: 9

Tamik Soziev
Tamik Soziev

Reputation: 14798

You could also use zbugs.com - just provide your website url and it will do everything for you.

Upvotes: -1

Ryan Li
Ryan Li

Reputation: 9330

If you are using it in a webpage, gzip is a configuration method in your web server. The file is gzipped by the server, sent to the browser. No manual action is needed. For Apache: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html.

If you are delivering the code to developers, you could use the gzip command.

Upvotes: 23

Related Questions