Flash of unstyled content

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
FOUC when loading Wikipedia's main page.

A flash of unstyled content (or flash of unstyled text)[1][2] is an instance where a web page appears briefly with the browser's default styles prior to loading an external CSS stylesheet, due to the web browser engine rendering the page before all information is retrieved.[3] The page corrects itself as soon as the style rules are loaded and applied; however, the shift may be distracting. Related problems include flash of invisible text and flash of faux text.[1][2]

Technical information[edit]

The issue was documented in an article named "Flash of Unstyled Content".[4] At first, FOUC appeared to be a browser problem unique to Internet Explorer but later became apparent in other browsers,[5][6] and has since been described as "a Safari epidemic".[7]

A flash of unstyled content is indifferent to changes in CSS or HTML versions. This problem, which leaves the core content unaffected, originates from a set of priorities programmed into the browser.[citation needed] As the browser collects HTML and all the ancillary files referenced in the markup, the browser builds the Document Object Model on-the-fly. The browser may choose to first display the text which it can parse the quickest.

Flashes of unstyled content are more prevalent now that HTML pages are more apt to reference multiple style sheets. Web pages often include style references to media other than the browser screen, such as CSS rules for printers and mobile devices. Web pages may import layers of style files, and reference alternative style sheets. Online advertisements and other inserted offsite content, like videos and search engines, often dictate their own style rules within their code block. The cascading nature of CSS rules encourages some browsers to wait until all the style datasets have been collected before applying them.

With the advent of JavaScript libraries such as jQuery which can be employed to further define and apply the styling of a web page, flashes of unstyled content have also become more prominent. In an attempt to avoid unstyled content, front-end developers may choose to hide all content until it is fully loaded, at which point a load event handler is triggered and the content appears, though an interruption of loading might leave behind a blank page, to which unstyled content would be preferable.

To emulate a flash of unstyled content, developers can use browser add-ons that are capable of disabling a web page's CSS on the fly. Firebug and Async CSS are such add-ons. Other techniques include manually stopping a page from completing the loading of CSS components. Another option entails using script-blocking tools.

While, by 2016, several different techniques had been developed to avoid undesired display behaviours,[2] a change in rendering behaviour in Google Chrome version 50, whereby stylesheets injected by JavaScript are prevented from blocking page loading, as required by the HTML5 specification, brought the situation to website creators' attentions again, particularly affecting users of Typekit, a web typography product from Adobe Systems.[1] Within 2 months, Adobe had changed the way in which their fonts were included into third-party websites in order to avoid the undesired rendering behaviour.[8]

See also[edit]

References[edit]

  1. ^ a b c Tim Brown (3 June 2016). "Regarding the Flash of Unstyled Text in Chrome 50". Adobe Typekit blog. Adobe Systems. Archived from the original on Sep 1, 2016. Retrieved 9 August 2016.
  2. ^ a b c Chris Coyier (1 April 2015). "FOIT, FOFT". CSS Tricks. Archived from the original on 15 August 2020. Retrieved 9 August 2016.
  3. ^ Boudreaux, Ryan (October 18, 2013). "How to prevent Flash of Unstyled Content on your websites". TechRepublic. Archived from the original on 2021-03-05. Retrieved 2021-10-09.
  4. ^ "Flash of Unstyled Content (FOUC)". Blue Robot. 2001. Archived from the original on May 13, 2015. Retrieved 12 October 2012.
  5. ^ "Flash of Unstyled Content (FOUC)". Bugzilla@Mozilla. Archived from the original on 5 November 2016. Retrieved 14 October 2016.
  6. ^ "Chromium Bugs containing 'FOUC'". bugs.chromium.org. Archived from the original on 18 October 2016. Retrieved 14 October 2016.
  7. ^ Dave Hyatt (1 September 2006). "The FOUC Problem". Surfin' Safari. The WebKit Open Source Project. Archived from the original on 30 August 2012. Retrieved 16 October 2012. The FOUC problem would normally be a minor occurrence. However with the advent of Google AdSense, FOUC has become a Safari epidemic. Because these Google ads not only execute inline script but access layout information that they often don't even end up using in the page, the problem of FOUC is much more severe than it should be.
  8. ^ Bram Stein (28 July 2016). "Changes to web font serving on Typekit". Adobe Typekit blog. Adobe Systems. Archived from the original on 15 August 2016. Retrieved 9 August 2016.