Avoiding Flash of Unstyled Content (FOUC)
I'm trying to progressively enhance a web application I'm developing. Similar to jQuery Mobile, the UI is defined using data attributes (<div data-role="page"/>) that JS then applies classes to. The problem is I'm getting the FOUC on page load and I haven't figured out a way around it yet. jQuery Mobile seems to have sorted out this issue. I've been searching through the jQuery Mobile source code, but so far I haven't found my answer. Currently, my page looks like this...
- <!doctype html>
- <html lang="en" class="no-js">
- <head>
- <meta charset="utf-8"/>
- <title>My Application</title>
- <link rel="stylesheet" href="/stylesheets/styles.combined.css"/>
- <script src="/javascripts/scripts.combined.js"></script>
- </head>
- <body>
- <div data-role="page">
- <header data-role="header">My Application</header>
- <div data-role="content">content</div>
- <footer data-role="footer">footer</footer>
- </div>
- </body>
- </html>
the scripts.combined.js file includes modernizr, jquery and all my plugins etc. Anyone have any suggestions?