Solved

gzip javascript using windows command line

Posted on 2010-02-23
5
808 Views
Last Modified: 2013-12-01
How i can gzip .js on windows using command line?
And what i have to add to .htaccess to display .gz?

currently i have zipped using gzip on linux and  no success with .htaccess:
(browser return invalid character)

AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]
0
Comment
Question by:mammouth
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:alien109
ID: 26832330
I wrote an article about how to gzip your javascript files and server them up:
http://blog.alien109.com/2009/03/17/gzip-your-javascript/

Let me know if you have any success, or I can try to help you further.
0
 
LVL 1

Author Comment

by:mammouth
ID: 26832433
lol, this is the article i used for my first try.

here what i've done:

i gzipped file.js using:
gzip file.js created file.js.gz.

i added the .htaccess block

when i hit my script, it return error:

illegal character
[Break on this error] ¿¿K
0
 
LVL 12

Expert Comment

by:alien109
ID: 26832679
Did you gzip on windows, or on the server? And is that a JavaScript error you are receiving (assuming so)?

I'm guessing you're getting some issues with the file getting garbled during decompression.

1. Have you verified the uncompressed version of the javascript file works
2. Tried compressing on the server
3. Do you have a link I can check?

Thanks. Any info is helpful.
0
 
LVL 1

Author Comment

by:mammouth
ID: 26832710
>> Did you gzip on windows, or on the server? And is that a JavaScript error you are receiving (assuming so)?

both windows and linux server

>>1. Have you verified the uncompressed version of the javascript file works
it works. but it's a minify js using google compiler.

>>3. Do you have a link I can check?
no, intranet.

0
 
LVL 12

Accepted Solution

by:
alien109 earned 125 total points
ID: 26832919
Hmm.

This is what I'd try:

1. Use an unminified version to rule out that could be causing the problem
2. don't gzip on windows - do it on the server so both compression and decompression is happening in the same environment

Can you post the gzipped version of the script? And just to make sure I'm on the right page - this is a javasrcipt error you are seeing?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question