views:

38

answers:

2

Hi, let's say I have a simple javascript like so:

$(document).ready(function(){

  if(login == "1") {
      showExtMenu(); //Show the logged in user the extra menu links
  } else {
      showRegMenu(); //Show the user the regular menu
  }

});

showExtMenu and showRegMenu populates an empty div with some html code. My question is, will the page render before the div is populated? I'm not interested in content that appears a few miliseconds after the page has been shown to the user.

Thanks for your time

+2  A: 

The page will be rendered for some time before the ready event is fired - it fires when the whole page is read, parsed and the whole DOM is constructed. If your page is large, the browser will display what it has gotten so far even if it's incomplete.

And in any case, as cletus notes in the comments, this looks like a server-side job.

Max Shawabkeh
Thanks, looks like a rewriting job for me.. sigh
soren.qvist
A: 

45 minutes into rewriting my code and I get that "This looks so much better" feeling. This is why I love stackoverflow.

soren.qvist