Friday, March 13, 2015

Strict mode in JavaScript and Bundling

I recently encountered an issue in one of my development projects which was causing our web application to break.

We noticed that the issue was only occurring when we deployed to our server in Release mode and note when we were running the application in Debug mode.

Well, the main difference between our Release mode and our Debug mode was that we were using Bundling in our application.

Therefore, something in one of our ScriptBundles was triggering a JavaScript error preventing other functionality in the web application to work correctly.

After doing some digging into the various script files, we discovered that one of the JavaScript files was using Strict mode:

Apparently, when this JavaScript file was being included in a Bundle, it was effectively breaking all other script files in the bundle!!

Therefore, the simple solution was to remove the "use strict" directive from the offending JavaScript file and our ScriptBundles were working correctly once again!

No comments:

Post a Comment