Current time: 12-01-2020, 07:11 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dns-prefetch. Anyone familiar?
04-12-2012, 03:47 AM (This post was last modified: 04-12-2012 04:17 AM by p83822.)
Post: #7
RE: dns-prefetch. Anyone familiar?
    I thought I'd have another look at this, now that dns-prefetch is official HTML5. I ran the following in FF (because I know how to disable FF's dns cache.) (And yes, this is truly vile!)

My expectation was that the look ahead preparser would recognise nodejs.org and http://www.w3.org as being in the html, but would not recognise http://www.w3schools.com as it is in the JS. My understanding being that look ahead preparsers do not read JS.

To my surprise, the DNS lookup for http://www.w3.org occurs after the sleep. (VRTA graphs this beautifully - see attached.) Pic1 is with dns-prefetch tags commented out, Pic2 with them in.

The horrid code?. Enjoy:

<html>
<head>
<meta charset="utf-8">
<!--<link rel="dns-prefetch" href="//nodejs.org">
<link rel="dns-prefetch" href="//www.w3.org">
<link rel="dns-prefetch" href="//www.w3schools.com">-->
</head>
<body>

<img src='http://nodejs.org/images/logo.png'/>

<script type="">
(function() {
var startTime = new Date().getTime();
while (new Date().getTime() < startTime + 1000);
}())
</script>

<img src='http://www.w3.org/2008/site/images/twitter-bird'/>

<script type="text/javascript">
(function() {
var d = function() {
var img = document.createElement("img");
img.src = "http://www.w3schools.com/images/w3schoolslogo.gif";
var s0 = document.getElementsByTagName('script')[0];
s0.parentNode.insertBefore(img, s0);
};
setTimeout(d, 1000);
}())
</script>
</body>
</html>
Daftness. Nothing will happen during the sleep. D'oh! Nice to know that the prefetch directive now though.


Attached File(s) Image(s)
   
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
dns-prefetch. Anyone familiar? - p83822 - 02-15-2010, 08:25 PM
RE: dns-prefetch. Anyone familiar? - p83822 - 04-12-2012 03:47 AM
RE: dns-prefetch. Anyone familiar? - pqdbr - 04-17-2012, 02:59 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)