next.js
191acdf8 - Remove expired link resources via MutationObserver during development (#48578)

Commit
2 years ago
Remove expired link resources via MutationObserver during development (#48578) Closes NEXT-684, closes #43396. This PR implements a temporary workaround to address the issue that some browsers are always caching CSS resources during the lifetime of a session. We re-introduce the versioning query to the resource to avoid that, and then use Mutation Observer to do GC manually on the client. Once Float handles that by itself, we can probably remove this. Note that correctly handling GC here is **required** for correctness, not an optimization. That's why it took us a while to address this (even this PR is still a temporary workaround). Imagine that if you have: ```css h1 { color: red; } ``` and then you changed it to: ```css h1 { font-size: 300px; } ``` During HMR, if we don't remove the old resources but only insert the new one, both will be applied and you will still see the `<h1>` in red, which is wrong. Here's a recording of this PR working correctly in Firefox: https://user-images.githubusercontent.com/3676859/233132831-b88e4d8d-aec9-48c4-9aa7-7c7a149b377d.mp4
Author
Parents
Loading