Question

Using ASP.NET's bundling and minification technique, I'm sort evaluating pros and cons of bundling standard libraries.

  • One of the critical point against bundling is that we won't be able to point to CDNs of these common libraries.
  • Also if something changes in our application's JavaScript, we would also force the client to download all the bundled 3rd party libraries.

Is there any way I could avoid these issues?

Was it helpful?

Solution

Bundling doesn't necessarily mean that you dump all your JS files in one bundle (hence one HTTP request). If that would have been the case, your arguments against it are all valid.

You can (and should) separate your bundles to accommodate their needs, and this will usually include the need to avoid the problems you presented.

For example:

// third-party
var librariesJS = new ScriptBundle("~/bundles/JsLibs")
                .Include("~/Scripts/Libs/jquery-2.0.3.js")
                .Include("~/Scripts/Libs/jquery.validate.js");

// mine
var appJS = new ScriptBundle("~/bundles/AppJS")
                    .Include("~/Scripts/_Globals.js")
                    .Include("~/Scripts/App.js");

// use CDN for third party code
librariesJS.CdnPath = "{CDN_URL}";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top