I updated jquery today through NuGet and I am now receiving the following error:
JavaScript critical error at line 1, column 11 http://localhost:53779/Scripts/jquery-1.9.0.min.map
SCRIPT1004: Expected ';'
Has anyone else come across this and can suggest a solution?
I stumbled on this by accident today and thought I should respond with an actual fix to this problem.
In my BundleConfig.cs I had the following:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-1.*"));
The wildcard was being used to get the latest version of jQuery, however, the Bundle Builder was picking up the map file as well.
By updating the BundleConfig.cs as follows:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
This solved the problem. The {version} token is a replacement that does a best match against the file. So now instead of all the files getting added you get a match on the library you are requesting for bundling and minification.
Source for this fix was found here http://jameschambers.com/2013/01/jquery-script-map-causing-critical-error-in-jquery-1-9-0/
The .map file is used for debugging (for example, there are new features in Chrome that let you 'map' into the non-minified version of the source).
If you're using bundling/minification you can link to the full version of the file, so you can delete (or move) the .map file safely and the code will work again, and you'll still get minification through the MVC framework.
As a note, I'm assuming you're not doing any jQuery library work here, and that you're not currently needing to access the non-minified version while debugging in the browser. More often than not, I'm a "consumer" of jQuery and tend not to look into the black box.
For more info, Elijah has some great info on the point of the source map and how you can use it.
http://www.elijahmanor.com/2013/01/the-magic-of-jquery-source-map.html
As well, if you want to implement a temporary workaround to address the map minification problem (may be related) you can check out this SO question: jquery 1.9.0 and modernizr cannot be minified with the ASP.NET Web Optimization Framework
Another possible cause of this issue is if you define two bundles with the same name (one script, one style):
bundles.Add(new ScriptBundle("~/bundles/bootstrap")
.Include("~/Scripts/bootstrap.js"));
bundles.Add(new StyleBundle("~/bundles/bootstrap")
.Include("~/Content/bootstrap.css"));
Then, in page, doing the following:
<%=Scripts.Render("~/bundles/bootstrap")%>
It will attempt to render the css as javascript and will fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With