| 1 |
<!doctype html> |
| 2 |
<html class="no-js"> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8" /> |
| 5 |
<title>Test: SCRIPT ordered via HeadJS</title> |
| 6 |
<link rel="stylesheet" href="style.min.css" /> |
| 7 |
<script> |
| 8 |
// calculate difference between zero and window.onload |
| 9 |
var now = new Date(); |
| 10 |
window.onload = function () { |
| 11 |
document.getElementById("content").style.display = "block"; |
| 12 |
document.getElementById("ms").innerHTML = (new Date()).getTime() - now.getTime(); |
| 13 |
}; |
| 14 |
</script> |
| 15 |
<script src="../dist/1.0.0/head.min.js"></script> |
| 16 |
<script> |
| 17 |
head.js( |
| 18 |
{ a: "http://ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools-yui-compressed.js" }, |
| 19 |
{ b: "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" }, |
| 20 |
{ c: "http://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js" }, |
| 21 |
{ d: "http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" }, |
| 22 |
{ e: "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" }); |
| 23 |
|
| 24 |
head.ready("a", function () { |
| 25 |
if (window.console) |
| 26 |
console.info("a"); |
| 27 |
}); |
| 28 |
head.ready("b", function () { |
| 29 |
if (window.console) |
| 30 |
console.info("b"); |
| 31 |
}); |
| 32 |
head.ready("c", function () { |
| 33 |
if (window.console) |
| 34 |
console.info("c"); |
| 35 |
}); |
| 36 |
head.ready("d", function () { |
| 37 |
if (window.console) |
| 38 |
console.info("d"); |
| 39 |
}); |
| 40 |
head.ready("e", function () { |
| 41 |
if (window.console) |
| 42 |
console.info("e"); |
| 43 |
}); |
| 44 |
</script> |
| 45 |
</head> |
| 46 |
<body> |
| 47 |
<div id="wrap"> |
| 48 |
|
| 49 |
<div id="nav" class="clear"> |
| 50 |
<a href="script.html">SCRIPT SRC <em>in head</em></a> |
| 51 |
<a href="script-bottom.html">SCRIPT SRC <em>on bottom</em></a> |
| 52 |
<a href="headjs.html">head.js <em>on head</em></a> |
| 53 |
<br /> |
| 54 |
</div> |
| 55 |
|
| 56 |
<div id="content" style="display: none"> |
| 57 |
|
| 58 |
<h1>head.js</h1> |
| 59 |
|
| 60 |
<div id="time"><span id="ms"></span>ms</div> |
| 61 |
|
| 62 |
<p> |
| 63 |
Press <strong>CTRL+SHIFT+R</strong> to reload with an empty cache = first impression. |
| 64 |
</p> |
| 65 |
|
| 66 |
<p> |
| 67 |
<strong>View source</strong> to see how scripts are provided. |
| 68 |
</p> |
| 69 |
|
| 70 |
<p> |
| 71 |
Time is calculated when <code>window.onload</code> fires. |
| 72 |
</p> |
| 73 |
|
| 74 |
<p> |
| 75 |
Try with different browsers. The time difference varies a lot. |
| 76 |
</p> |
| 77 |
|
| 78 |
<p class="details"> |
| 79 |
head.js() calls are always separate from the page rendering. Does not matter whether you load on HEAD or on bottom. You can also load programmatically on demand. |
| 80 |
|
| 81 |
</p> |
| 82 |
|
| 83 |
</div> |
| 84 |
|
| 85 |
<div id="footer"> |
| 86 |
<a href="/site/unit.html">« Back</a> |
| 87 |
| <a href="https://github.com/headjs/headjs/issues">found a bug?</a> |
| 88 |
</div> |
| 89 |
|
| 90 |
</div> |
| 91 |
</body> |
| 92 |
</html> |