Hacker News new | ask | show | jobs
by sjwright 5367 days ago
If you really do have a legitimate 1500 msec process occurring on the home page, try to flush as much of the HTML to the browser before you start the heavy lifting. Ideally, you could have the entire HTML shell delivered immediately, and the content elements slotted in at the very end (using DOM manipulation).

If you can put all the content inside a <script/> tag at the very end of the HTML, it will at least give the browser a chance to find and download all the page's resources (css, Jquery, logo image, etc etc).

e.g.

  <html>
  <head><link rel="stylesheet"></head>
  <body>
    <h1>Home Page</h1>
    <p id="content1">cheap content</p>
    <p id="content2">place-holder content</p>
    <p id="content3">more content</p>
  ~~flush~~
    <script>
    $("#content2").html("expensive content");
    </script>
  </body>
  </html>