FOUT (Flash of Unstyled Text) prevention


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }) ();

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.