Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Bundles vs Javascript modules

As a ASP.NET MVC developer, I am trying to wrap my head around JavaScript AMD modules and libraries like RequireJS.

What is the relationship between ASP.NET MVC ScriptBundles and RequireJS?

In a large site with lots of JavaScript, should I be using both? Or one of them?

Should I integrate RequireJS with Bundles using IBundleTransform?

like image 296
Klas Mellbourn Avatar asked Oct 18 '12 06:10

Klas Mellbourn


1 Answers

I wouldn't see using the two of these together. With Bundles you would have all your JavaScript loaded, ideally into just one or two bundles, on your layout controller. In production it would be optimized (combining into one file, minimised, cached and compressed etc).

RequireJS the way I see some of it is if you are being more granular about what JS is loaded and then you can use it's terse syntax to ensure a certain file is loaded before invoking some of that file's JavaScript.

I would recommend using Bundles since you are working with asp.net-mvc. They are pretty to use and work very well. I had used a similar pre mvc4 framework called Combres which was similar and this approach works very well for apps I think. It may be different for read only web sites.

like image 182
dove Avatar answered Sep 21 '22 13:09

dove