Solved

gzip javascript using windows command line

Posted on 2010-02-23
5
812 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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.

632 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