Fonts.com Web Fonts and FOUT Control
A Brief History
With the start of the Fonts.com Web Fonts service, the FOUT (flash of unstyled text) phenomenon was a wide-spread problem. To remedy this issue we added code to our JavaScript implementation.
Our first method included hiding the visibility of elements on pages that used Web fonts. We then crafted a more efficient and cleaner method of preventing FOUT – we use a single class to hide only the text for elements using Web fonts. We then strip that class's properties when the Web fonts are ready to display. One thing to note is that the class is left on these elements in the DOM; however, without properties, the class has no meaning and is invisible to visitors, save for those using some manner of developer tools.
Back to the Present
Since the introduction of Web fonts, broadband connections have grown more common, and browsers have matured in handling embedded fonts. So has the Fonts.com Web Fonts service. We have adjusted our JavaScript in two key ways:
FOUT-prevention is disabled by defaultNow there are configuration options that can be set before loading our JavaScript in order toturn FOUT-prevention back on and traverse through the DOM to remove the mti_font_element class
The goodies
Below is a sample usage of the FOUT configuration options. To utilize them, simply define the options before including the SCRIPT tag for your Web fonts project. If any of the options are omitted, their default values will be used instead.