Posted By

pussard on 07/31/11


Tagged


Versions (?)

FOUT (Flash of Unstyled Text) prevention


 / Published in: JavaScript
 

URL: http://paulirish.com/2009/fighting-the-font-face-fout/

  1. (function(){
  2. // if firefox 3.5+, hide content till load (or 3 seconds) to prevent FOUT
  3. var d = document,
  4. e = d.documentElement,
  5. s = d.createElement('style'),
  6. r = document.getElementsByTagName('script')[0];
  7. if (e.style.MozTransform === '') { // gecko 1.9.1 inference
  8. s.textContent = 'body { visibility: hidden }';
  9. r.parentNode.insertBefore(s, r);
  10. function f() {
  11. s.parentNode && s.parentNode.removeChild(s);
  12. }
  13. addEventListener('load', f, false);
  14. setTimeout(f, 3000);
  15. }
  16. }) ();

Report this snippet  

You need to login to post a comment.