0

I'm building the ASP.NET MVC application containing widgets - user can define in the administration panel which widgets (which are being in fact partial views) will be used on page. Each widget has references to jquery library which is common for all widgets but also to jsquery plugin file which contains the logic specified for particular widget.

The problem which I found is to load efficiently only the scripts needed on the page (based on the user defined set of widgets) and minify them in one scripts.min.js file.

The build in MVC bundling allows me to define some sets of scripts, by the problem is that I don't know the exact set of widgets and I don't like to list all possible combination, I need to do it dynamically (on server side - from the perspective of performance), based on user choice.

There are Require.js library, but it will do everything on user side, and there will be many requests for each one jquery file and an the end the combination of everything into one file.

Do you have any ideas, how to make this working in efficient way?

Steve Macculan
  • 2,292
  • 5
  • 22
  • 32
  • do users experience performance issues if you load everything in one go? – trailmax Feb 01 '14 at 16:11
  • Now I've got a dozen of widgets, some of the plugins are quite heavy and there are no need to load them each time. Serving only the required scripts will decrease the page loading time a bit. – Steve Macculan Feb 01 '14 at 19:30
  • 1
    In that case I can think of a simple solution - have a bundle per widget. Widget actually contains scripts it requires. Other one will be, as you say, dynamically include scripts into bundle depending on user's widgets. And for that there is no ready solution, you'll have to come up yourself. Some sort of helper that checks what what user, what widgets are for the user and build the bundle. But in this case I'm not sure if bundle is built every time if it is cached. There could be the case that bundle is new every time and not cached. – trailmax Feb 02 '14 at 01:12

0 Answers0