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. PythonCrawl自学日志

    2016-09-10 PythonCrawl自学日志 1.python及Selenium的安装 (1)开发环境使用的是VS2015 Community.python3.5.Selenium3.0BET ...

  2. git fork同步原作者

    从github上获取源代码,一种是直接下载,但是无法改动后提交. 一种是fork一下,但是和原作者同步麻烦. 所以我找到了四个命令,解决同步问题. 以后建议大家fork一下,主要是哪天对源码熟悉了,想 ...

  3. stream的Read、Write方法实例

    , bytes.Length)) > ) , readBytes-);//8为偏移量,10为数量                    }                }            ...

  4. 从clone()谈protected

    看到Object的clone()是protected的,然后看到<java2认证考试指南>上描述:一个对象只能请求其他对象的克隆,后者的类与被克隆对象属于同一类,或是被克隆对象的子类. e ...

  5. WebService积累

    1.缺点,无法传输复杂对象:如无法序列化key/value结构的类型参数以及相关一维集合接口(Hashtable等打上标签[Serializable]即可序列化,不过继承的IDictionary并不可 ...

  6. BZOJ 1738: [Usaco2005 mar]Ombrophobic Bovines 发抖的牛

    Description 约翰的牛们非常害怕淋雨,那会使他们瑟瑟发抖.他们打算安装一个下雨报警器,并且安排了一个撤退计划.他们需要计算最少的让所有牛进入雨棚的时间.    牛们在农场的F(1≤F≤200 ...

  7. [topcoder]BusinessTasks

    水题,不值一提.http://community.topcoder.com/stat?c=problem_statement&pm=1585&rd=6535 import java.u ...

  8. asp.net上传图片(简单)

    FileUpload: protected void UploadButton_Click(object sender, EventArgs e) { : Convert.ToInt64(Reques ...

  9. Altium Designer学习:PCB只看当前层

    1 Shift+S          这个快捷键能高亮当前层,并且使其他层变成灰色,见下图:       2 隐藏指定层 在图中右下角的地方,右键,会弹出一个选项条,选择Hide Layers,可以选 ...

  10. RxJava开发精要5 – Observables变换

    原文出自<RxJava Essentials> 原文作者 : Ivan Morgillo 译文出自 : 开发技术前线 www.devtf.cn 转载声明: 本译文已授权开发者头条享有独家转 ...