domready源码,domready实现代码,js实现domready的源代码。

jquery的domready源码,require.js的domready源代码

.

[domReady sourceCode]
https://raw.githubusercontent.com/requirejs/domReady/latest/domReady.js

/**
* @license RequireJS domReady 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/domReady for details
*/
/*jslint */
/*global require: false, define: false, requirejs: false,
window: false, clearInterval: false, document: false,
self: false, setInterval: false */ define(function () {
'use strict'; var isTop, testDiv, scrollIntervalId,
isBrowser = typeof window !== "undefined" && window.document,
isPageLoaded = !isBrowser,
doc = isBrowser ? document : null,
readyCalls = []; function runCallbacks(callbacks) {
var i;
for (i = ; i < callbacks.length; i += ) {
callbacks[i](doc);
}
} function callReady() {
var callbacks = readyCalls; if (isPageLoaded) {
//Call the DOM ready callbacks
if (callbacks.length) {
readyCalls = [];
runCallbacks(callbacks);
}
}
} /**
* Sets the page as loaded.
*/
function pageLoaded() {
if (!isPageLoaded) {
isPageLoaded = true;
if (scrollIntervalId) {
clearInterval(scrollIntervalId);
} callReady();
}
} if (isBrowser) {
if (document.addEventListener) {
//Standards. Hooray! Assumption here that if standards based,
//it knows about DOMContentLoaded.
document.addEventListener("DOMContentLoaded", pageLoaded, false);
window.addEventListener("load", pageLoaded, false);
} else if (window.attachEvent) {
window.attachEvent("onload", pageLoaded); testDiv = document.createElement('div');
try {
isTop = window.frameElement === null;
} catch (e) {} //DOMContentLoaded approximation that uses a doScroll, as found by
//Diego Perini: http://javascript.nwbox.com/IEContentLoaded/,
//but modified by other contributors, including jdalton
if (testDiv.doScroll && isTop && window.external) {
scrollIntervalId = setInterval(function () {
try {
testDiv.doScroll();
pageLoaded();
} catch (e) {}
}, );
}
} //Check if document already complete, and if so, just trigger page load
//listeners. Latest webkit browsers also use "interactive", and
//will fire the onDOMContentLoaded before "interactive" but not after
//entering "interactive" or "complete". More details:
//http://dev.w3.org/html5/spec/the-end.html#the-end
//http://stackoverflow.com/questions/3665561/document-readystate-of-interactive-vs-ondomcontentloaded
//Hmm, this is more complicated on further use, see "firing too early"
//bug: https://github.com/requirejs/domReady/issues/1
//so removing the || document.readyState === "interactive" test.
//There is still a window.onload binding that should get fired if
//DOMContentLoaded is missed.
if (document.readyState === "complete") {
pageLoaded();
}
} /** START OF PUBLIC API **/ /**
* Registers a callback for DOM ready. If DOM is already ready, the
* callback is called immediately.
* @param {Function} callback
*/
function domReady(callback) {
if (isPageLoaded) {
callback(doc);
} else {
readyCalls.push(callback);
}
return domReady;
} domReady.version = '2.0.1'; /**
* Loader Plugin API method
*/
domReady.load = function (name, req, onLoad, config) {
if (config.isBuild) {
onLoad(null);
} else {
domReady(onLoad);
}
}; /** END OF PUBLIC API **/ return domReady;
});

.

domReady source code, domready源码的更多相关文章

  1. <Flume><Source Code><Flume源码阅读笔记>

    Overview source采集的日志首先会传入ChannelProcessor, 在其内首先会通过Interceptors进行过滤加工,然后通过ChannelSelector选择channel. ...

  2. 编译Code::Blocks源码 with MinGW on Win

    Build Code::Blocks源码 ---By 狂徒归来 CodeBlocks是一款非常优秀的IDE !可惜的是没有64位的版本,而且本来是轻量级别的IDE就应该够轻,能够像记事本工具一样,迅速 ...

  3. google code 上源码的下载方法

    SVN全称是Subversion,是Apache的一个子项目 ,具体能够到SVN中文站(http://www.subversion.org.cn/)去了解下.Google Code是Google的一个 ...

  4. DirectShow中写push模式的source filter流程 + 源码(内附具体凝视)

    尽管网上已有非常多关于DirectShow写source filter的资料.只是非常多刚開始学的朋友总说讲的不是非常清楚(可能当中作者省略了很多他觉得简 单的过程).读者总希望看到象第一步怎么做,第 ...

  5. 下载google code中源码的几个工具

    Google code 一般以三种命令行方式提供源代码,格式如下: hg clone https://code.google.com/p/xxx/ git clone https://code.goo ...

  6. vs2008编译FileZilla服务端源码

    vs2008编译FileZilla服务端源码 FileZilla服务端下载地址:https://download.filezilla-project.org/server/.FileZilla服务端源 ...

  7. VSCode & outline & source code

    VSCode & outline & source code Dart 源码学习 outline 速览 dart-core List class instance-methods ht ...

  8. Asp.Net MVC4+EF6 Code First 权限管理系统 源码下载

    这个权限管理系统是基于在@TZHSWEET 的权限管理系统之上做的修改.@TZHSWEET 那个是DB first. 这个是Code First.源码下载:http://download.csdn.n ...

  9. Hadoop2.5.2源码编译及导入Eclipse

    前言:由于官网提供的64位hadoop是没有编译的,所以当我们用到64位的hadoop时,需要在自己的64位linux系统上编译hadoop源码.另外,要想在eclipse里查看hadoop源码,修改 ...

随机推荐

  1. 为什么要有binary-to-text encoding?

    在wikipedia上看MIME的介绍的时候,有一节是关于Content-Transfer-Encoding的,里面提到了binary-to-text encoding,我就想,既然计算机中的信息使用 ...

  2. jQuery实现鼠标移到元素上动态提示消息框效果

    当光标移动到某些元素上时,会弹出像tips的提示框,这种效果想必大家都有见到过吧,下面有个不错的示例,大家可以感受下 当光标移动到某些元素上时,会弹出像tips的提示框. 复制代码代码如下: < ...

  3. centos 关闭触摸板,触摸板点击

    yum install xorg-x11-apps xinput –list 由图可以看出俺的本本触摸板ID为14,于是可以通过以下命令开启与关闭它: 禁止touchpad:xinput set-in ...

  4. 《C和指针》读书笔记——第三章 数据

    1.typedef:为各种数据类型定义新名字 typedef char  *ptr_to_char; ptr_to_char a;//声明a是一个指向字符的指针. 2.链接属性:extern;stat ...

  5. python import

    在执行 import module 时 会从 1 当前目录 2 pythonpath(可以通过 os.sys.path 查看) 3 python 安装目录   b import 了 a, c impo ...

  6. RS232转RS485电路图分析

    在电子发烧友网站上,看到RS232转RS485的一个电路图,如下图所示.元件主要是HN232CP和MAX485CPA,也就是TTL转232电路和TTL转485电路的结合体.可是这个电路却不好分析,几经 ...

  7. 一步步学习ASP.NET MVC3 (10)——@Ajax,JavaScriptResult(1)

    请注明转载地址:http://www.cnblogs.com/arhat 首先老魏先说一下抱歉,昨天由于在安装CentOS,Mono,Jexus配置Linux环境下的ASP.NET运行环境,花费了不少 ...

  8. java枚举类型enum的使用

    2015-10-24 java达人 Java 中 的枚举类型采用关键字enum 来定义,从jdk1.5才有的新类型,所有的枚举类型都是继承自Enum 类型.要了解枚举类型,建议大家先打开jdk 中的E ...

  9. mysql查询结果中文显示成了问号

    在mysql的配置文件my.ini中的[mysqld]项中加这两句 character-set-server = utf8 collation-server = utf8_general_ci 在任务 ...

  10. Hadoop 2.4.0完全分布式平台搭建、配置、安装

    一:系统安装与配置 Hadoop选择下载2.4.0 http://hadoop.apache.org / http://mirror.bit.edu.cn/apache/hadoop/common/h ...