Hiding unstyled div that shows on page load

In the spirit of sharing web development tips and techniques:

Have you come across a situation where you have a javascript carousel or accordian that is fairly content heavy? When the page loads the list items or the div content flash onto the screen until the page loads and then the whole page “pops” into place.  Very annoying effect when you’re on a slower connection.

I dealt with this problem on the home page of the new auditel.co.uk site.  On this page I’m using the excellent jQuery library and a modified version of the useful plugin called jflow that allows for autoscrolling.  The technique below was documented on the Learning jQuery site and uses a combination of javascript and css to hide the extra content until the page finishes loading.

<!– etc. –>

// The style below can be placed in your external css file
<style type=”text/css”>
.js .flash {display: none;}

// Usual javascript loaded below, note the .addclass() method used BEFORE the $(document).ready()
<script type=”text/javascript” src=”/scripts/jquery.js”></script>
<script type=”text/javascript”>
$(document).ready(function() {
// Stuff to do as soon as the DOM is ready, in my case this has my settings for the jflow plugin

// The javascript below will make your div content below once the page is loaded
<script type=”text/javascript”>
$(window).bind(‘load’, function() {


// Included in the body of the html are the set of divs that make up the carousel or accordian
Show the content in the first div.
<div class=”flash showthis”>
Hide the content in the second div.

<!– etc. –>


Hope the code above helps someone, can be one of those problems that cause hours of frustrated searching around.  Please let me know if you see any problems or can recommend a better method.