View Full Version : Page loads slowly sometimes with Dynamic Clock


Golfie
08-14-2006, 09:48 PM
I just recently added a dynamic clock to my website and notice that sometimes when you refresh the page, it takes a few seconds to load the whole page.. But then other times I refresh and everything loads instantly.

I was wondering if anyone keep point me in the direction of a different one, or maybe I am doing something wrong with this one.

Here is the javascript file:


function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN() .getUTCDate(),tN().getUTCHours(),tN().getUTCMinute s(),tN().getUTCSeconds()); x.setTime(x.getTime()+0); return x; }
function tN(){ return new Date(); }
function lZ(x){ return (x>9)?x:'0'+x; }
function dT(){ if(fr==0){ fr=1; document.write('<span id="tP">'+eval(oT)+'</span>'); } document.getElementById('tP').innerHTML=eval(oT); setTimeout('dT()',1000); }
var dN=new Array('Sunday','Monday','Tuesday','Wednesday','Thu rsday','Friday','Saturday'),mN=new Array('January','February','March','April','May',' June','July','August','September','October','Novem ber','December'),fr=0,oT="dN[tS().getDay()]+' '+mN[tS().getMonth()]+' '+tS().getDate()+' '+lZ(tS().getHours())+':'+lZ(tS().getMinutes())+': '+lZ(tS().getSeconds())";

And here is how I am displaying it on my index:

<script language="JavaScript" src="clock.js"></script>
<script language="JavaScript">dT();</script>