Question

I have Visual Studio 2012 with Web Essentials 2012 installed and I am using it to minify my javascript files. Then I am using the Telerik ScriptRegistrar to create bundles on the fly.

When deploying to test, we discovered an issue where Web Essentials is stripping the last semicolon out of each file resulting in invalid javascript. The reason that last semicolon is there is so that when the files are bundled, the browser doesn't interpret the first line of any jquery plug-in as part of the last line of the previous file. This typically happens when the previous file ends with the jQuery shorthand for document.ready as in:

$(function () {
    alert('This bloody code will break if the next file contains a plug in');
});

Whenever this happens in a bundle, the browser throws an exception fairly early in the page life cycle and none of the javascript on the page gets loaded.

Does anyone know of any way to stop Web Essentials 2012 from stripping out that last semi-colon? Alternatively, is there something else we can do to our scripts to keep them from clobbering one another?

Was it helpful?

Solution

This will be fixed in Web Essentials 1.9, but you can get the fix now from the latest build: http://madskristensen.net/custom/webessentials2012.vsix?1.8.9.1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top