├── component.json ├── README.md ├── bower.json ├── ready.min.js ├── composer.json └── ready.js /component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "domready", 3 | "repo": "components/domready", 4 | "description": "bullet proof DOM ready method", 5 | "version": "0.2.11", 6 | "keywords": [ 7 | "ender", 8 | "domready", 9 | "dom" 10 | ], 11 | "main": "ready.js", 12 | "scripts": [ 13 | "ready.js" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | domReady 2 | ======== 3 | 4 | Shim repository for [domReady](http://github.com/ded/domready). 5 | 6 | Package Managers 7 | ---------------- 8 | 9 | * [Bower](http://bower.io): `components-domready` 10 | * [Component](https://github.com/component/component): `components/domready` 11 | * [Composer](http://packagist.org/packages/components/font-awesome): `components/domready` 12 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "components-domready", 3 | "description": "bullet proof DOM ready method", 4 | "version": "0.2.11", 5 | "homepage": "http://github.com/components/domready", 6 | "author": "Dustin Diaz (http://dustindiaz.com)", 7 | "keywords": [ 8 | "ender", 9 | "domready", 10 | "dom" 11 | ], 12 | "main": "ready.js", 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/components/domready.git" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ready.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * domready (c) Dustin Diaz 2012 - License MIT 3 | */ 4 | !function(a,ctx,b){typeof module!="undefined"?module.exports=b():typeof define=="function"&&typeof define.amd=="object"?define(b):ctx[a]=b()}("domready",this,function(a){function m(a){l=1;while(a=b.shift())a()}var b=[],c,d=!1,e=document,f=e.documentElement,g=f.doScroll,h="DOMContentLoaded",i="addEventListener",j="onreadystatechange",k="readyState",l=/^loade|c/.test(e[k]);return e[i]&&e[i](h,c=function(){e.removeEventListener(h,c,d),m()},d),g&&e.attachEvent(j,c=function(){/^c/.test(e[k])&&(e.detachEvent(j,c),m())}),a=g?function(c){self!=top?l?c():b.push(c):function(){try{f.doScroll("left")}catch(b){return setTimeout(function(){a(c)},50)}c()}()}:function(a){l?a():b.push(a)}}) 5 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "components/domready", 3 | "description": "bullet proof DOM ready method", 4 | "type": "component", 5 | "homepage": "https://github.com/ded/domready", 6 | "license": "MIT", 7 | "support": { 8 | "issues": "https://github.com/ded/domready/issues", 9 | "source": "https://github.com/ded/domready" 10 | }, 11 | "authors": [ 12 | { 13 | "name": "Dustin Diaz", 14 | "homepage": "http://github.com/ded" 15 | } 16 | ], 17 | "extra": { 18 | "component": { 19 | "main": "ready.js", 20 | "scripts": [ 21 | "ready.js" 22 | ], 23 | "files": [ 24 | "ready.min.js" 25 | ] 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ready.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * domready (c) Dustin Diaz 2012 - License MIT 3 | */ 4 | !function (name, context, definition) { 5 | if (typeof module != 'undefined') module.exports = definition() 6 | else if (typeof define == 'function' && typeof define.amd == 'object') define(definition) 7 | else context[name] = definition() 8 | }('domready', this, function (ready) { 9 | 10 | var fns = [], fn, f = false 11 | , doc = document 12 | , testEl = doc.documentElement 13 | , hack = testEl.doScroll 14 | , domContentLoaded = 'DOMContentLoaded' 15 | , addEventListener = 'addEventListener' 16 | , onreadystatechange = 'onreadystatechange' 17 | , readyState = 'readyState' 18 | , loaded = /^loade|c/.test(doc[readyState]) 19 | 20 | function flush(f) { 21 | loaded = 1 22 | while (f = fns.shift()) f() 23 | } 24 | 25 | doc[addEventListener] && doc[addEventListener](domContentLoaded, fn = function () { 26 | doc.removeEventListener(domContentLoaded, fn, f) 27 | flush() 28 | }, f) 29 | 30 | 31 | hack && doc.attachEvent(onreadystatechange, fn = function () { 32 | if (/^c/.test(doc[readyState])) { 33 | doc.detachEvent(onreadystatechange, fn) 34 | flush() 35 | } 36 | }) 37 | 38 | return (ready = hack ? 39 | function (fn) { 40 | self != top ? 41 | loaded ? fn() : fns.push(fn) : 42 | function () { 43 | try { 44 | testEl.doScroll('left') 45 | } catch (e) { 46 | return setTimeout(function() { ready(fn) }, 50) 47 | } 48 | fn() 49 | }() 50 | } : 51 | function (fn) { 52 | loaded ? fn() : fns.push(fn) 53 | }) 54 | }) 55 | --------------------------------------------------------------------------------