Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
move Math.random usage up to before we take a time snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
bluesmoon committed Apr 5, 2012
1 parent 46734f3 commit 3efe2e2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,29 @@ var impl = {
gen_url: "",

start: function() {
var random = Math.floor(Math.random()*(2147483647)).toString(36);
var random = Math.floor(Math.random()*(2147483647)).toString(36),
cache_bust = "" + (new Date().getTime()) + (Math.random());

this.gen_url = this.base_url.replace(/\*/, random);

impl.img = new Image();
impl.img.onload = impl.A_loaded;

impl.t_start = new Date().getTime();
impl.img.src = this.gen_url + "image-l.gif?t="
+ (new Date().getTime()) + Math.random();
impl.img.src = this.gen_url + "image-l.gif?t=" + cache_bust;
},

A_loaded: function() {
var cache_bust;
impl.t_dns = new Date().getTime() - impl.t_start;

cache_bust = "" + (new Date().getTime()) + (Math.random());

impl.img = new Image();
impl.img.onload = impl.B_loaded;

impl.t_start = new Date().getTime();
impl.img.src = impl.gen_url + "image-l.gif?t="
+ (new Date().getTime()) + Math.random();
impl.img.src = impl.gen_url + "image-l.gif?t=" + cache_bust;
},

B_loaded: function() {
Expand Down

0 comments on commit 3efe2e2

Please sign in to comment.