Friday, December 31, 2010

Render before Run

Rendered <body/> immediately

To get the content of an HTML page up as soon as possible put <script/> tags after content to avoid delaying the rendering until after the script loads.  Possibly even after the <body/>.

<body>
  <div>display content before loading script...</div>
  <script src="http://o.aolcdn.com/dojo/1.5/dojo/dojo.xd.js.uncompressed.js"></script>
</body>

A script loader does the same thing (LABjs):


<head>
    <script src="scripts/lab.js" type="text/javascript"></script>
    <script type="text/javascript">
        $LAB
        .script("http://o.aolcdn.com/dojo/1.5/dojo/dojo.xd.js.uncompressed.js");
    </script>
</head>

<body>
  <div>display content before loading script...</div>
</body>


No comments:

Post a Comment