ligershark / WebOptimizer

A bundler and minifier for ASP.NET Core
Apache License 2.0
750 stars 113 forks source link

Multiple instances using same bundle #290

Open gfaessler opened 8 months ago

gfaessler commented 8 months ago

We are using weboptimizer on the Umbraco CMS to bundle css and js files. On the CMS, the customer can use widgets and can have multiple instances of the same widget on the same page. For exemple he can use 3 instance of an Image Gallery widget.

If we include the bundle in the [Image Gallery] widget view using the tag helper : <link rel="stylesheet" href="/css/bundle.css" />, the tag will be repeated each time the widget is used in the page which seems not optimal.

To avoid this we could integrate all bundles once on the root view but that means there will be potentially a lot of unused css/js on the page.

We also tried to use the method AddFileVersionToPath(string path) to include the bundle by code if required but it seems that this method doesn't work when using the bundle path.

Any hint would be welcome. I have the feeling that we took a wrong turn somewhere.