.netumbracoclient-dependencyweboptimizer

Multiple widget instances with weboptimizer


We are using weboptimizer on an Umbraco 12 .NET projet for pre-bundling and minifying css/js files. We were using clienddependency on previous Asp.NET Umbraco 7 projects.

We are currently asking ourselves how to handle the case where a customer adds on a page multiple instances of a widget which itself includes and tags interpreted by the weboptimizer tag helper.

If we include them directly as or tag in the widget view, they will be processed by the tag helper and will be duplicated in the page source if multiple instances of the widget are used which is not optimal. We didn't find any option on weboptimizer to eliminate duplicate or entries.

Another possibility would be to integrate all possible and tags once but that means there will be potentially a lot of unused and tags on the page.

I have the feeling we are not using weboptimizer correctly or that weboptimzer isn't adapted for our needs as I didn't find any similar question regarding this topic so far.

Any hint or help on best practice regarding this scenario would be welcome.


Solution

  • There is a public method AddFileVersionToPath(string path) which adds version query parameter to the specified file path and returns path containing the version query string

    https://github.com/ligershark/WebOptimizer/blob/master/src/WebOptimizer.Core/FileVersionProvider.cs#L54