导航首页 » 技术教程 » jQuery ready()和onload的加载耗时分析
jQuery ready()和onload的加载耗时分析 104 2024-02-19   

本文实例讲述了jQuery ready()和onload的加载耗时。分享给大家供大家参考,具体如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="http://www.gimoo.net/t/1812/js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
  var startTime = new Date().getTime();
  $(document).ready(function(){
    test1();
 })
 function test1(){
   var endTime2 = new Date().getTime();
   var a = endTime2 - startTime;
   $("<div>jQuery的ready() : "+a+" ms</div>").appendTo("body");
 }
 function test2(){
    var endTime1 = new Date().getTime();
    var b = endTime1 - startTime;
    $("<p>JavaScript的window.onload : "+b+" ms</p>").appendTo("body");
 }
</script>
</head>
<body onload="test2();">
  <img src="http://www.gimoo.net/t/1812/img/demo.jpg" style="width:200px;height:200px;"/>
</body>
</html>

效果图如下:

查看图片

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery常用插件及用法总结》、《jQuery操作json数据技巧汇总》、《jQuery扩展技巧总结》、《jQuery拖拽特效与技巧总结》、《jQuery表格(table)操作技巧汇总》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》

希望本文所述对大家jQuery程序设计有所帮助。



!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103