Skip to content

Instantly share code, notes, and snippets.

Last active October 8, 2021 08:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Is Chrome enable stylesheets asynchronously?
<p>Hello world</p>
<button id="btn">Toggle CSS</button>
const stylesheet = document.querySelector('#purecss');
const btn = document.querySelector('#btn');
btn.addEventListener('click', async () => {
// Notice we're within an async function
stylesheet.disabled = !stylesheet.disabled;
debugger; // 👈 At this point, the stylesheet should reflect the state set in the previous line
Copy link

mmazzarolo commented Oct 7, 2021

In Chrome (on the right), when we hit the breakpoint after re-enabling the stylesheet it still shows the unstyled content (and the pending network request???)
In other browsers the stylesheet is enabled/disabled synchronously.

Screenshot 2021-10-07 at 7 18 23 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment