What is FOUC (Flash of Unstyled Content) and How to Fix It on WordPress Sites

Edited

Overview

FOUC, or Flash of Unstyled Content, is a visual glitch that happens when your WordPress site briefly shows unstyled or raw HTML before the proper CSS is applied. This can make your website appear broken for a second and create a poor user experience.

This issue is usually caused by how CSS and fonts are loaded. In many cases, it results from development mistakes in the theme or plugin code or dynamic content loading methods like JavaScript-injected styles.


How It Works

When a browser loads a webpage, it first renders the HTML and then applies styles defined in the CSS files. If these styles are loaded too late—because they're enqueued in the footer, included with @import, or injected via JavaScript—the HTML will render before the CSS is ready. This causes the brief "flash" of unstyled content known as FOUC.

Some common causes of FOUC on WordPress sites include:

  • Stylesheets are being loaded in the footer instead of the header

  • Using @import inside CSS files

  • JavaScript-injected styles (common with page builders)

  • Web fonts loading slowly or without proper configuration

  • Dynamic CSS generated by shortcodes or plugins after page load


Step-by-Step: How to Fix FOUC in WordPress

Step 1: Enqueue All Styles Properly in the Header

Make sure your theme or plugin uses the wp_enqueue_scripts action hook to load styles early in the page load. Styles enqueued in the footer or too late in the render process can result in FOUC.

Step 2: Avoid Using @import in CSS

Using @import in your CSS files delays loading because the browser has to first download the main CSS, then discover and fetch the imported styles. Instead, enqueue all CSS files individually using WordPress functions.

Step 3: Use Proper Font Loading Techniques

Web fonts can cause FOUC or FOIT (Flash of Invisible Text). To prevent this, use the font-display: swap property when loading fonts. This tells the browser to show fallback fonts immediately while the custom fonts are loading.

Step 4: Reduce JavaScript-Based Styling

Avoid relying on JavaScript to apply important styles. Some page builders and custom themes delay rendering styles until JavaScript has finished running. This can cause a flash of unstyled content, especially on slower devices or connections.


Pro tip: If you're troubleshooting FOUC, disable caching temporarily and inspect your site using Chrome DevTools with "Disable cache" enabled. Check how quickly your CSS and fonts load. You can also simulate a slower connection (like 3G) to see if the FOUC becomes more noticeable. This can help pinpoint styles or fonts that are loading too late.