[fix]-Missing Javascript “.map” file for Underscore.js when loading ASP.NET web page
Scenario :
An ASP.NET web page is running on Azure. Suddenly a notification from browser raised which was trying to download a ".map" for Underscore.js. JQuery creates ".map" files as debugging aids for Javascript source files (".js"). However, a look at the Scripts directory for the web site reveals that this only happens for some JQuery source files and not all. But the browser is trying to load a ".map" file for Underscore.js which is not part of JQuery.
Error :
The exact error that occurs in the Chrome Debugger Console tab is:
GET http://myazureapp.cloudapp.net/Scripts/underscore-min.map 404 (Not Found)
Fix :
- The issue occurs because of source mapping. This allows to debug with readable code in the browser's developer tools when working with minified JS files.
- The minified version of Underscore.js file has this command at the end of the file:
//# sourceMappingURL=underscore-min.map
Hence the browser's developer’s tools will try to download
underscore-min.map on encounter with this line. To avoid the download,
1. The line of command must be removed from underscore-min.js.
2. Add underscore-min.map and underscore.js to the project file to avoid further chaos.
Fixes are applicable to the following versions of Javascript :
Related Error Tags :
- javascript - missing .map resource?
- Fetching the value from a map by index using Underscore.js