开发者

ySlow, Mod Deflate, cPanel Website Optimizer & Javascript

开发者 https://www.devze.com 2022-12-15 10:03 出处:网络
I just got around to installing mod_deflate on my server. I also added the following to my Website Optimizer in cPanel:

I just got around to installing mod_deflate on my server. I also added the following to my Website Optimizer in cPanel:

text/html text/plain text/xml text/css text/j开发者_StackOverflow社区s text/javascript

Now, the site shows considerable improvement in loading time (almost 3x!), but ySlow is still giving me an "E" rating for "Compress Components with gZip". It shows 4 .js components not being Compressed.

The problem is that the whole website except the .JS components is being gZipped properly. Everything else, including the inline javascript, HTML and other MIME types have been Compressed. I've not added anything to the htaccess, since I think Website Optimizer takes care of it. But I'm still not able to figure out what the problem is?

Any ideas?

Thanks,

B.


Have you checked what MIME type the JavaScript is being served as? You listed text/javascript in the list of types to gzip, but sometimes JavaScript isn't served under that MIME type; it may be served under text/ecmascript, application/x-javascript, or might be getting a default type like text/plain. Browsers don't generally care what type is sent in the Content-Type, as it's the type listed in the <script> tag that they pay attention to, so the content type for your JavaScript files might be something odd.


Bingo! Realized what the problem is. For anyone else who seems to be facing the same problem:

text/javascript MIME is obsolete. Changed it to application/javascript and it works live a charm! :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号