博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jquery ready 延迟
阅读量:7035 次
发布时间:2019-06-28

本文共 1250 字,大约阅读时间需要 4 分钟。

$.holdReady(true);//延迟

$.holdReady(false);//解延迟

 

用于下载文件的时候,异步操作

$.holdReady(true);

$.getScript("a.js",function(){

$.holdReady(false);

})

$.holdReady(true);

$.getScript("b.js",function(){

$.holdReady(false);

})

......

 内部酷似锁的机制 锁了2次,都加载了之后解锁2次,才继续往下...

 源码:

1 // Hold (or release) the ready event 2     holdReady: function( hold ) { 3         if ( hold ) { 4             jQuery.readyWait++; 5         } else { 6             jQuery.ready( true ); 7         } 8     }, 9 10     // Handle when the DOM is ready11     ready: function( wait ) {12 13         // Abort if there are pending holds or we're already ready14         if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {15             return;16         }17 18         // Remember that the DOM is ready19         jQuery.isReady = true;20 21         // If a normal DOM Ready event fired, decrement, and wait if need be22         if ( wait !== true && --jQuery.readyWait > 0 ) {23             return;24         }25 26         // If there are functions bound, to execute27         readyList.resolveWith( document, [ jQuery ] );28 29         // Trigger any bound ready events30         if ( jQuery.fn.trigger ) {31             jQuery( document ).trigger("ready").off("ready");32         }33     },

 

转载地址:http://wwnal.baihongyu.com/

你可能感兴趣的文章
我所积累的20条编程经验
查看>>
VisualStudio.DTE 对象可以通过检索 GetService() 方法
查看>>
一个简单的EBNF范式的实现
查看>>
as3 TweenMax TweenLite方法
查看>>
随笔css的样式
查看>>
VI 配置文件(略全)
查看>>
752. Open the Lock
查看>>
Git 分布式版本控制的常见命令
查看>>
windows添加删除mysql 服务
查看>>
删除HTML标记
查看>>
请教关于vs2008英文版连接中文版的sql2005的问题
查看>>
防止页面重复刷新
查看>>
redis_1 安装和简单使用
查看>>
Django 学习笔记(二)第一个网页
查看>>
MySQL与SQL的触发器的不同写法
查看>>
Using Vertex Texture Displacement for Realistic Water Rendering
查看>>
IM多类型holder封装
查看>>
[目标检测] 从 R-CNN 到 Fast R-CNN
查看>>
杭电1213--How Many Tables(并查集)
查看>>
PHP学习之路(四)
查看>>