PSA: Dynamically inserted StyleSheet will not block loading.

784 views
Skip to first unread message

Tsuyoshi Horo

unread,
Jan 21, 2016, 9:13:06 PM1/21/16
to blink-dev, chromi...@chromium.org
After [1] landed, dynamically inserted StyleSheet will not block loading.

Before this patch, Chrome would stop parsing HTML when downloading programmatically injected CSS.
But according to the HTML5 spec [2], the injected CSS should not be blocking.

Example:
  <script>
  var link = document.createElement('link');
  link.setAttribute('rel', 'stylesheet');
  link.setAttribute('type', 'text/css');
  // This CSS returns "div { color: red; }" with a 10 seconds delay
  link.setAttribute('href', 'really-really-slow.css');
  document.head.appendChild(link);
  </script>
  <div>This should be black then red.</div>

Before [1]:
  The text in the div doesn't show up initially. After about 10 seconds (when really-really-slow.css is loaded), it shows up and it's red from the beginning.

After [1]:
  The text in the div is black initially. After about 10 seconds (when really-really-slow.css is loaded), it turns red.





Reply all
Reply to author
Forward
0 new messages