Luke Childs
8 years ago
commit
0b414c91d0
6 changed files with 164 additions and 0 deletions
@ -0,0 +1,72 @@ |
|||||
|
## Node |
||||
|
|
||||
|
# Logs |
||||
|
logs |
||||
|
*.log |
||||
|
npm-debug.log* |
||||
|
|
||||
|
# Runtime data |
||||
|
pids |
||||
|
*.pid |
||||
|
*.seed |
||||
|
*.pid.lock |
||||
|
|
||||
|
# Directory for instrumented libs generated by jscoverage/JSCover |
||||
|
lib-cov |
||||
|
|
||||
|
# Coverage directory used by tools like istanbul |
||||
|
coverage |
||||
|
|
||||
|
# nyc test coverage |
||||
|
.nyc_output |
||||
|
|
||||
|
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) |
||||
|
.grunt |
||||
|
|
||||
|
# node-waf configuration |
||||
|
.lock-wscript |
||||
|
|
||||
|
# Compiled binary addons (http://nodejs.org/api/addons.html) |
||||
|
build/Release |
||||
|
|
||||
|
# Dependency directories |
||||
|
node_modules |
||||
|
jspm_packages |
||||
|
|
||||
|
# Optional npm cache directory |
||||
|
.npm |
||||
|
|
||||
|
# Optional eslint cache |
||||
|
.eslintcache |
||||
|
|
||||
|
# Optional REPL history |
||||
|
.node_repl_history |
||||
|
|
||||
|
## OS X |
||||
|
|
||||
|
*.DS_Store |
||||
|
.AppleDouble |
||||
|
.LSOverride |
||||
|
|
||||
|
# Icon must end with two \r |
||||
|
Icon |
||||
|
|
||||
|
|
||||
|
# Thumbnails |
||||
|
._* |
||||
|
|
||||
|
# Files that might appear in the root of a volume |
||||
|
.DocumentRevisions-V100 |
||||
|
.fseventsd |
||||
|
.Spotlight-V100 |
||||
|
.TemporaryItems |
||||
|
.Trashes |
||||
|
.VolumeIcon.icns |
||||
|
.com.apple.timemachine.donotpresent |
||||
|
|
||||
|
# Directories potentially created on remote AFP share |
||||
|
.AppleDB |
||||
|
.AppleDesktop |
||||
|
Network Trash Folder |
||||
|
Temporary Items |
||||
|
.apdisk |
@ -0,0 +1,6 @@ |
|||||
|
language: node_js |
||||
|
node_js: node |
||||
|
script: npm run lint |
||||
|
notifications: |
||||
|
email: |
||||
|
on_success: never |
@ -0,0 +1,21 @@ |
|||||
|
MIT License |
||||
|
|
||||
|
Copyright (c) 2016 Luke Childs |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
of this software and associated documentation files (the "Software"), to deal |
||||
|
in the Software without restriction, including without limitation the rights |
||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
copies of the Software, and to permit persons to whom the Software is |
||||
|
furnished to do so, subject to the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be included in all |
||||
|
copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
|
SOFTWARE. |
@ -0,0 +1,15 @@ |
|||||
|
# domloaded |
||||
|
|
||||
|
> Check when the DOM is loaded |
||||
|
|
||||
|
[![Build Status](https://travis-ci.org/lukechilds/domloaded.svg?branch=master)](https://travis-ci.org/lukechilds/domloaded) |
||||
|
|
||||
|
## Install |
||||
|
|
||||
|
```shell |
||||
|
npm install --save domloaded |
||||
|
``` |
||||
|
|
||||
|
## License |
||||
|
|
||||
|
MIT © Luke Childs |
@ -0,0 +1,36 @@ |
|||||
|
{ |
||||
|
"name": "domloaded", |
||||
|
"version": "0.0.0", |
||||
|
"description": "Check when the DOM is loaded", |
||||
|
"main": "src/index.js", |
||||
|
"scripts": { |
||||
|
"lint": "xo", |
||||
|
"test": "echo \"Error: no test specified\" && exit 1" |
||||
|
}, |
||||
|
"xo": { |
||||
|
"env": "browser" |
||||
|
}, |
||||
|
"repository": { |
||||
|
"type": "git", |
||||
|
"url": "git+https://github.com/lukechilds/domloaded.git" |
||||
|
}, |
||||
|
"keywords": [ |
||||
|
"check", |
||||
|
"dom", |
||||
|
"loaded", |
||||
|
"ready", |
||||
|
"promise", |
||||
|
"async", |
||||
|
"asynchronous" |
||||
|
], |
||||
|
"author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)", |
||||
|
"license": "MIT", |
||||
|
"bugs": { |
||||
|
"url": "https://github.com/lukechilds/domloaded/issues" |
||||
|
}, |
||||
|
"homepage": "https://github.com/lukechilds/domloaded", |
||||
|
"dependencies": {}, |
||||
|
"devDependencies": { |
||||
|
"xo": "^0.17.1" |
||||
|
} |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
// Global
|
||||
|
const doc = document; |
||||
|
|
||||
|
// Run callback when DOM is loaded
|
||||
|
module.exports = cb => { |
||||
|
// Run now if DOM has already loaded
|
||||
|
if (['interactive', 'complete'].indexOf(doc.readyState) >= 0) { |
||||
|
cb(); |
||||
|
|
||||
|
// Otherwise wait for DOM
|
||||
|
} else { |
||||
|
doc.addEventListener('DOMContentLoaded', cb); |
||||
|
} |
||||
|
}; |
Loading…
Reference in new issue