Trainee4Life
Trainee4Life

Reputation: 2273

Should you bundle and minify - jQuery and other third party libraries?

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

Is there any way I could avoid these issues?

Upvotes: 1

Views: 758

Answers (1)

haim770
haim770

Reputation: 49095

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}";

Upvotes: 3

Related Questions