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?