We are using the ASP.NET Web Optimization Framework with bundles and minification. One bundle just contains jquery and modernizr. This all worked fine with jquery 1.8.3 but
Reading the answers, even the accepted answer, the advised solution to this problem is to modify your scripts so the bundler has no trouble with this. This makes no sense to me, this is clearly a bug of the bundler not concatenating different scripts properly, specifically the bundler has a trouble when the last line of the n script is a normal line comment
// this is the last line of the n script
and then your next script does not start with a single line comment
function(){ var ...
the bundler, is by default configured with a ;
as a the ConcatenationToken
so the bundled code ends up being something like this:
// this is the last line of the n script;function(){ var ...
Surely the script loading fails with a syntax error somewhere.
It has been proposed to modify the latest line of the script to not be an inline comment, make it a multiline comment, so when the code ends with */
the parser will be ok with a function declaration or something else right after it.
I don't like modifying my scripts, many are authored by somebody else (jquery, etc.) and I don't want to modify them, what if I have to upgrade them and will find this bug again after I upgrade a website and it doesn't run with debug="true"
in the config.
I come with this solution working better for me
bundles.Add(new ScriptBundle("~/bundles/mobile") {
ConcatenationToken = ";\r\n" }
.Include("~/Scripts/jquery-1.11.3*",
"~/Scripts/jquery-timeago*",
"~/Scripts/jquery.mobile-1.4.5*",
This way we force the bundler to always separate the scripts with a new line character. It should do this by default when the last line of the previous script is a single line comment.