0

I am publishing an asp.net website and when I try to run it, the CSS and the JS files are not loading correctly. When I open the Chrome debugger tools, all the JS files are giving the following error

"Uncaught SyntaxError: Unexpected token ILLEGAL"

and when I view the js files from the developer tools, they contain only junk characters. The thing is when I view the files on the file system, they appear to be fine but when I view them from the developer tools or from a browser e.g. http://localhost/MyApp/jquery.js, I see only junk characters

I've been trying to find out what's wrong but this error keeps coming. it was working before and all of a sudden I am getting this. enter image description here

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Sushil
  • 2,837
  • 4
  • 21
  • 29
  • Current tools (Chrome Developer Tools / Fiddler etc) should be able to uncompress those and show them in a friendly view. – Erik Philips Mar 31 '15 at 20:58
  • Hi Erik, I was debugging it through the chrome developer tools and it wasn't decompressing. the screen shot is taken from Chrome Developer tools. guess the server was compressing and sending it to the client. – Sushil Mar 31 '15 at 21:04
  • Check out this SO Answer. http://stackoverflow.com/a/7149719/209259 – Erik Philips Mar 31 '15 at 21:17
  • Hi Erik, what I meant to say was that my code was not being minified, my js was getting replaced by some unreadable junk characters which my browser was unable to interpret. minified javascript files can be read by the browsers. a specific setting in my config file was somehow turning it into junk characters which was then sent on to the client side. the link that you've shared is talking about formatting minified files and its not relevant to my question. thanks anyways for helping. – Sushil Apr 01 '15 at 00:02
  • Sorry I couldn't tell, the image is too small to debug. – Erik Philips Apr 01 '15 at 14:54
  • Sorry about the image Erik. I thought we could enlarge it in Stack Overflow. Thanks again for your time. – Sushil Apr 01 '15 at 16:01

1 Answers1

2

It turns out that there was a key in my web.config that was compressing the javascript files on the fly.

I had the GZip compression key in my config file which was causing this issue. here's the key

<add name="Headers_GZipOutput" type="Headers_GZipOutput"/>

I commented this and it started working.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Sushil
  • 2,837
  • 4
  • 21
  • 29