mini-css-extract-plugin icon indicating copy to clipboard operation
mini-css-extract-plugin copied to clipboard

Does browser always refetch if the new created link tag has the same `href` ?

Open JSerFeng opened this issue 4 months ago • 8 comments

What's the purpose for setting preload rel after fetching the new style

When a css file updates, mini-css-extract will fetch the new link tag, and once done, it will set rel as preload and as as css.

https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/index.js#L1103-L1107

Is this just for disabling the new style rendering ?

Make a link whose href is the same with an already loaded link tag, will browser fetch the new style ?

I have a link tag whose href is foo.css, and the update happens fast, mini-css-extract creates an new link tag, whose href is still foo.css, but sometimes the browser doesn't make request at all, I assume that this is the default behavior for browsers: when you create a link tag whose href is the same as an already loaded tag in a short time, browsers can assume these 2 tags are the same and do not make requests.

This happens usually when enable lazy compilation

I tried to find out in HTML spec and Dom spec but no luck, maybe is my carelessness. Still trying to make an repro.

JSerFeng avatar Aug 15 '25 03:08 JSerFeng