-
Notifications
You must be signed in to change notification settings - Fork 68
/
domReady.js
43 lines (39 loc) · 1.34 KB
/
domReady.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/** @license MIT License (c) copyright 2011-2013 original author or authors */
/**
* wire/domReady
* A base wire/domReady module that plugins can use if they need domReady. Simply
* add 'wire/domReady' to your plugin module dependencies
* (e.g. require(['wire/domReady', ...], function(domReady, ...) { ... })) and you're
* set.
*
* wire is part of the cujo.js family of libraries (http://cujojs.com/)
*
* Licensed under the MIT License at:
* http://www.opensource.org/licenses/mit-license.php
*
* Returns a function that accepts a callback to be called when the DOM is ready.
*
* You can also use your AMD loader's paths config to map wire/domReady to whatever
* domReady function you might want to use. See documentation for your AMD loader
* for specific instructions. For curl.js and requirejs, it will be something like:
*
* paths: {
* 'wire/domReady': 'path/to/my/domReady'
* }
*
* @author Brian Cavalier
* @author John Hann
*/
(function(global) {
define(['require'], function(req) {
// Try require.ready first
return (global.require && global.require.ready) || function (cb) {
// If it's not available, assume a domReady! plugin is available
req(['domReady!'], function () {
// Using domReady! as a plugin will automatically wait for domReady
// so we can just call the callback.
cb();
});
};
});
})(this);