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

Phylicia ·
更新时间:2024-09-21
· 853 次阅读

本文实例讲述了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" style="width:200px;height:200px;"/> </body> </html>

效果图如下:

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

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



ready jQuery

需要 登录 后方可回复, 如果你还没有账号请 注册新账号