dotvvm icon indicating copy to clipboard operation
dotvvm copied to clipboard

Add support for priority hints using `fetchpriority` on JS and CSS resources

Open acizmarik opened this issue 2 years ago • 3 comments

This is a feature requested by BusinessPack team.

The main purpose is to provide more granular control over how are resources actually loaded. As such, if used correctly, this could provide better loading times and thus better user experience.

New API IMO this can be either implemented by adding new overloads to DotVVM.Framework.ResourceManagement.ResourceRepositoryExtensions or by adding new optional parameters to existing methods (although this would need to wait for next major release).

Implementation / Rendering It seems like there are only three possible values for fetchpriority attribute: low, high and auto. The value auto can be omitted (it is the default value) and therefore we need to render only low and high values.

Limitations As of writing this issue, it seems like only Chromium-based browsers support this. https://caniuse.com/mdn-html_elements_img_fetchpriority.

acizmarik avatar Oct 11 '22 11:10 acizmarik

Adding an optional parameter is source compatible change, so it'd be fine to do in 4.1 release. But I don't think that many people will want to use it, so we could only add new property to the StylesheetResource class.

As of writing this issue, it seems like only Chromium-based browsers support this. https://caniuse.com/mdn-html_elements_img_fetchpriority.

It's not even standardized. The major use case of this are images, IMO, and there is nothing stopping you from using it. I'd prefer to wait for standardization when it comes to resources, unless someone comes with a benchmark where it helps significantly.

exyi avatar Oct 11 '22 12:10 exyi

You are right, I would probably wait for the standardization as well. Also it is pretty clear that it is possible to render additional attributes using current API.

Once and if this gets standardized, we can reconsider whether to add helper methods / parameters for this. Unless, of course someone comes with a good reason why this should be added sooner.

acizmarik avatar Oct 11 '22 13:10 acizmarik