Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 'jquery-2.0.2.min.map not found'

I'm getting this error in Google Chrome developer tools:

jquery-2.0.2.min.map not found

I found a way to get rid of it by removing this line from my jquery-2.0.2.min.js:

//@ sourceMappingURL=jquery-2.0.2.min.map

However, I don't believe this was a good idea, since this may be just a temporary fix that may be a problem in the future. Since I don't really understand the nature of this error and the goofy solution: what's causing this error and is there a better fix for it?

Apparently, this is not a question related to jQuery 2.0.2 only. A very similar Stack Overflow question with a great explanation is jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found). I hope this will shed some light on the situation.

like image 337
Anton Belev Avatar asked Aug 28 '13 12:08

Anton Belev


4 Answers

1. Download the map file and uncompressed version of jquery. Put them with minified version. JavaScript

2. Include minified version into your HTML HTML

3. Check in Chrome Chrome

4. Read Introduction to JavaScript Source Maps

5. Get familiar with Debugging JavaScript

like image 193
kayz1 Avatar answered Nov 20 '22 19:11

kayz1


You should have a file included in your download of jquery-2.0.2 called jquery-2.0.2.min.map make sure it is in the same location as jquery-2.0.2.min.js and you should be good to go.

If you don't have a copy you can download it here: http://code.jquery.com/jquery-2.0.2.min.map

Some more background about this from the jQuery website.

Starting with jQuery 1.9, we also make available sourcemap files that can be used to debug the compressed file in sourcemap-aware browsers such as Google Chrome. The map file is not required for users to run jQuery, it just improves the developer's debugger experience.

like image 41
Rob Schmuecker Avatar answered Nov 20 '22 18:11

Rob Schmuecker


As it is announced in jQuery 1.11.0/2.1.0 Beta 2 Released the source map comment will be removed so the issue will not appear in newer versions of jQuery.

Anyway, if you need to use a source map, it still be available:

We’ll still be generating and distributing sourcemaps, but you will need to add the appropriate sourcemap comment at the end of the minified file if the browser does not support manually associating map files (currently, none do). If you generate your own jQuery file using the custom build process, the sourcemap comment will be present in the minified file and the map is generated; you can either leave it in and use sourcemaps or edit it out and ignore the map file entirely.

Here you find more details about the changes.

like image 4
gotqn Avatar answered Nov 20 '22 19:11

gotqn


You can remove the 404 by removing the line

//@ sourceMappingURL=jquery-2.1.2.min.map

from the top part of your jQuery file.

Purpose of a source map

Basically it's a way to map a combined/minified file back to an unbuilt state. When you build for production, along with minifying and combining your JavaScript files, you generate a source map which holds information about your original files. When you query a certain line and column number in your generated JavaScript you can do a lookup in the source map which returns the original location.

like image 1
SharpCoder Avatar answered Nov 20 '22 18:11

SharpCoder