Should I group all of my .js files into one large bundle?

Posted by Scottie on Programmers See other posts from Programmers or by Scottie
Published on 2014-07-14T21:51:32Z Indexed on 2014/08/21 4:30 UTC
Read the original article Hit count: 450

One of the difficulties I'm running into with my current project is that the previous developer spaghetti'd the javascript code in lots of different files. We have modal dialogs that are reused in different places and I find that the same .js file is often loaded twice.

My thinking is that I'd like to just load all of the .js files in _Layout.cshtml, and that way I know it's loaded once and only once. Also, the client should only have to download this file once as well. It should be cached and therefore shouldn't really be a performance hit, except for the first page load.

I should probably note that I am using ASP.Net bundling as well and loading most of the jQuery/bootstrap/etc from CDN's.

Is there anything else that I'm not thinking of that would cause problems here? Should I bundle everything into a single file?

© Programmers or respective owner

Related posts about JavaScript

Related posts about ASP.NET