Permalink
Browse files

move Math.random usage up to before we take a time snapshot

  • Loading branch information...
1 parent 46734f3 commit 3efe2e2ab0bee2393365f3ddc4ecf302cac146b9 @bluesmoon committed Apr 5, 2012
Showing with 7 additions and 5 deletions.
  1. +7 −5 dns.js
View
@@ -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() {

0 comments on commit 3efe2e2

Please sign in to comment.