jQuery ready()和onload的加载耗时分析
jQuery ready()和onload的加载耗时分析
发布时间:2016-12-30 来源:查字典编辑
摘要:本文实例讲述了jQueryready()和onload的加载耗时。分享给大家供大家参考,具体如下:varstartTime=newDate(...

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

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="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="img/demo.jpg"/> </body> </html>

效果图如下:

jQuery ready()和onload的加载耗时分析1

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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类