96

I have a web page that is part of a ASP.NET web site running on Azure. It's run fine for quite a while now. Out of the blue, I am suddenly having a problem with the browser trying to download a ".map" for Underscore.js. I did some reading and apparently JQuery creates ".map" files as debugging aids for Javascript source files (".js"). However, if I look at the Scripts directory for my web site I see that this only happens for some JQuery source files and not all and I am not sure what the pattern is.

However, why would the browser be trying to load a "map" file for Underscore.js which is not part of JQuery? Also, why would this suddenly start happening? I added Underscore.js to the web page quite some time ago and never had this problem before.

The exact error I get when I look in the Chrome Debugger Console tab is:

GET http://myazureapp.cloudapp.net/Scripts/underscore-min.map 404 (Not Found) Scripts/underscore-min.map:1

BenV
  • 12,052
  • 13
  • 64
  • 92
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227

1 Answers1

228

What you're experiencing is source mapping. This allows you to debug with readable code in your browser's developer tools when working with minified JS files.

The minified version of Underscore has this line at the end of the file:

//# sourceMappingURL=underscore-min.map

Your browser's developers tools will try to download underscore-min.map when encountering this line.

If you want to get rid of the error, either:

  1. Remove that line from underscore-min.js
  2. Add underscore-min.map and underscore.js to your project.
Alastair
  • 6,837
  • 4
  • 35
  • 29
RoryKoehein
  • 3,113
  • 1
  • 14
  • 13
  • 1
    Since I dont want to touch source codes (would be lost in next upgrade), is there any grunt configuration to enforce different name instead of "underscore-min.map" ? Or any other easier way instead of manually changing the code? – lubosdz Aug 03 '15 at 11:01
  • @lubosdz did you try the point 2 in the answer? In my case I simply created an additional empty file with the same name as the original but with a .map extension instead of .js (e.g. foo.min.js => add empty foo.min.map). This keeps the browser happy and does not affect source code or updates. – pasx Sep 04 '15 at 01:16