javascript - It takes 2 seconds for my clock to appear on the html page -


i set 2 files js create clock timing event , html file show clock.. when run html file, takes 2 seconds clock appear. how make run faster??

my code found below... html file

window.onload = startcurrenttime;    function startcurrenttime() {    var today = new date();    var h = today.gethours();    var min = today.getminutes();    var s = today.getseconds();    var y = today.getfullyear();    var mon = today.getmonth() + 1;    var d = today.getdate();    min = checktime(min);    s = checktime(s);    mon = checktime(mon);    d = checktime(d);    //	document.getelementbyid('todaylocaltime').innerhtml = "&nbsp;local current date:"+ d + "/" + mon + "/" +y + "&nbsp;local current time:" + h + ":" + min + ":" + s + " sgt ";    document.getelementbyid('todaylocaltime').innerhtml = "<font size=3>current time " + h + ":" + min + ":" + s + "</font>";    var t = settimeout(startcurrenttime, 1000);  }    function checktime(i) {    if (i < 10) {      = "0" +    }; // add 0 in front of numbers < 10    return i;  }
font {    color: black  }
<table>    <tr>      <!-- <td style="color:white;background-color:#000000;">events today: <font></font></td> -->      <!-- <td style="color:white;">events today: <font></font></td> -->      <td style="color:white;">        <font size="3">events today: </font>      </td>      <!-- <td id="totalattack" style="color:white;background-color:#000000;">0 &nbsp;&nbsp;</td> -->      <td id="totalattack" style="color:white;">        <font size="3">0</font>      </td>      <!-- <td id="todaylocaltime"style="color:white;background-color:#000000;position: absolute; left: 235px;width:300px""></td> -->      <td id="todaylocaltime" style="color:white;position: absolute; left: 235px;width:300px"></td>    </tr>  </table>  </div>

how make run faster???i use defer , async make run faster. not work.......is possible make clock appear when reload page rather taking time clock appear.please me....thank you


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -