Rule #1 in website optimization is to enable GZip compression on the web server. This is very easy using web.config as explained here. However, some web servers have disabled automatic compression of JavaScript files, because they are served with the content type: application/x-javascript.

For these web servers we can use a web.config trick to change the content type of JavaScript files to text/javascript. This is a completely valid content type supported by all browsers.

Just paste the following XML snippet in to your web.config’s <system.webServer> section.

<staticContent>
  <remove fileExtension=".js"/>
  <mimeMap fileExtension=".js" mimeType="text/javascript" />
</staticContent>

Chances are that you don’t have this issue, since it seems to only apply to some hosters, but now you know how to get around it should you ever end up in the situation with uncompressed JavaScript files.

Comments

Internet marketing

Thanks for sharing ....... &lt;a href="http://www.indiawebdesigncompany.in/"&gt;Website Design Company in Bangalore&lt;/a&gt;

Internet marketing

Internet marketing

Thank you for publishing this information. This post is amazing. http://www.bangalorewebdesigncompany.in/services.html

Internet marketing

Anthom

I never ended up in the situation with uncompressed JavaScript files. But thanks for sharing this trick. http://www.anthom-services.com

Anthom

website marketing company

thanks for this men, I am a big follower of you regarding asp.net, and finally I got your blog and it solves my problem.

website marketing company

Comments are closed