* 'skip': 'return !!window.Example', (or) null
*
* // Added during implementation
+ * 'skipped': true,
* 'script': ...,
* 'style': ...,
* 'messages': { 'key': 'value' },
/* Private methods */
function getMarker() {
- // Cached ?
- if ( $marker ) {
- return $marker;
- }
-
- $marker = $( 'meta[name="ResourceLoaderDynamicStyles"]' );
- if ( $marker.length ) {
- return $marker;
+ // Cached
+ if ( !$marker ) {
+ $marker = $( 'meta[name="ResourceLoaderDynamicStyles"]' );
+ if ( !$marker.length ) {
+ mw.log( 'No <meta name="ResourceLoaderDynamicStyles"> found, inserting dynamically' );
+ $marker = $( '<meta>' ).attr( 'name', 'ResourceLoaderDynamicStyles' ).appendTo( 'head' );
+ }
}
- mw.log( 'getMarker> No <meta name="ResourceLoaderDynamicStyles"> found, inserting dynamically.' );
- $marker = $( '<meta>' ).attr( 'name', 'ResourceLoaderDynamicStyles' ).appendTo( 'head' );
-
return $marker;
}
skip = new Function( registry[module].skip );
registry[module].skip = null;
if ( skip() ) {
+ registry[module].skipped = true;
registry[module].dependencies = [];
registry[module].state = 'ready';
handlePending( module );
crossDomain: true,
cache: true,
async: true
- } ).always( function () {
- if ( callback ) {
- callback();
- }
- } );
+ } ).always( callback );
} else {
/*jshint evil:true */
document.write( mw.html.element( 'script', { 'src': src }, '' ) );
/**
* Execute a function as soon as one or more required modules are ready.
*
- * If the required modules are already loaded, the function will be
- * executed immediately and the modules will not be reloaded.
- *
* Example of inline dependency on OOjs:
*
* mw.loader.using( 'oojs', function () {
*
* @param {string|Array} modules Either the name of a module, array of modules,
* or a URL of an external script or style
- * @param {string} [type='text/javascript'] mime-type to use if calling with a URL of an
+ * @param {string} [type='text/javascript'] MIME type to use if calling with a URL of an
* external script or style; acceptable values are "text/css" and
* "text/javascript"; if no type is provided, text/javascript is assumed.
* @param {boolean} [async] Whether to load modules asynchronously.