PSA: Dynamically inserted StyleSheet will not block loading.

786 kali dilihat
Langsung ke pesan pertama yang belum dibaca

Tsuyoshi Horo

belum dibaca,
21 Jan 2016, 21.13.0621/01/16
kepadablink-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.





Balas ke semua
Balas ke penulis
Teruskan
0 pesan baru