I'm using jQuery to modify the style of some pages in a large set of existing Web pages. This works, but the problem I have is that, for longer pages, the page is briefly visible with the wrong styles before the javascript kicks in and transforms the page.
I'm using this kind of thing (the alerts are just to emphasize the problem):
$(document).ready(function(){
...
alert("at this point the page is visible unstyled");
$('body').addClass('myStyle');
alert("now page looks like I want it to");
...
}
How do I prevent the browser from displaying the page until $(document).ready(function() completes?
EDIT
Note: I can't change the HTML of the pages (they're not mine). All I can do is swap in a replacement JavaScript file and work with what's already in the HTML