3 ms·
Yep, you're right that that's how jQuery works [1]. I'm not an expert in this, but I would expect requestAnimationFrame to be quicker than DOMContentLoaded, bec
by acjohnson55 11y ago
Yep, you're right that that's how jQuery works [1]. I'm not an expert in this, but I would expect requestAnimationFrame to be quicker than DOMContentLoaded, because it should occur before a paint [2], rather than after the event fires, which is presumably afterward. If the stylesheet is in cache, this gives the browser a chance to load it before the first render, to prevent a flash of unstyled content.
[1] https://github.com/jquery/jquery/blob/dabd5ba96c05279b3ffb052db5b8d17f75996694/src/core/ready.js#L60-L64 https://github.com/jquery/jquery/blob/dabd5ba96c05279b3ffb05...
[2] https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame https://developer.mozilla.org/en-US/docs/Web/API/window/requ...