for ( j = 0; j < jobs.length; j += 1 ) {
if ( compare(
filter( 'ready', jobs[j].dependencies ),
for ( j = 0; j < jobs.length; j += 1 ) {
if ( compare(
filter( 'ready', jobs[j].dependencies ),
* @param src String: URL to script, will be used as the src attribute in the script tag
* @param callback Function: Optional callback which will be run when the script is done
*/
* @param src String: URL to script, will be used as the src attribute in the script tag
* @param callback Function: Optional callback which will be run when the script is done
*/
var done = false, script, head;
if ( ready || !blocking ) {
// jQuery's getScript method is NOT better than doing this the old-fashioned way
var done = false, script, head;
if ( ready || !blocking ) {
// jQuery's getScript method is NOT better than doing this the old-fashioned way
- nestedAddScript = function ( arr, callback, i ) {
+ nestedAddScript = function ( arr, callback, blocking, i ) {
- nestedAddScript( script, markModuleReady, 0 );
+ nestedAddScript( script, markModuleReady, registry[module].blocking, 0 );
* @param dependencies string module name or array of string module names
* @param ready function callback to execute when all dependencies are ready
* @param error function callback to execute when any dependency fails
* @param dependencies string module name or array of string module names
* @param ready function callback to execute when all dependencies are ready
* @param error function callback to execute when any dependency fails
- function request( dependencies, ready, error ) {
+ function request( dependencies, ready, error, blocking ) {
var regItemDeps, regItemDepLen, n;
// Allow calling by single module name
var regItemDeps, regItemDepLen, n;
// Allow calling by single module name
for ( n = 0; n < dependencies.length; n += 1 ) {
if ( $.inArray( dependencies[n], queue ) === -1 ) {
queue[queue.length] = dependencies[n];
for ( n = 0; n < dependencies.length; n += 1 ) {
if ( $.inArray( dependencies[n], queue ) === -1 ) {
queue[queue.length] = dependencies[n];
* @param moduleMap {Object}: Module map, see buildModulesString()
* @param currReqBase {Object}: Object with other parameters (other than 'modules') to use in the request
* @param sourceLoadScript {String}: URL of load.php
* @param moduleMap {Object}: Module map, see buildModulesString()
* @param currReqBase {Object}: Object with other parameters (other than 'modules') to use in the request
* @param sourceLoadScript {String}: URL of load.php
- function doRequest( moduleMap, currReqBase, sourceLoadScript ) {
+ function doRequest( moduleMap, currReqBase, sourceLoadScript, blocking ) {
request = sortQuery( request );
// Asynchronously append a script tag to the end of the body
// Append &* to avoid triggering the IE6 extension check
request = sortQuery( request );
// Asynchronously append a script tag to the end of the body
// Append &* to avoid triggering the IE6 extension check
var reqBase, splits, maxQueryLength, q, b, bSource, bGroup, bSourceGroup,
source, group, g, i, modules, maxVersion, sourceLoadScript,
currReqBase, currReqBaseLength, moduleMap, l,
var reqBase, splits, maxQueryLength, q, b, bSource, bGroup, bSourceGroup,
source, group, g, i, modules, maxVersion, sourceLoadScript,
currReqBase, currReqBaseLength, moduleMap, l,
- lastDotIndex, prefix, suffix, bytesAdded;
+ lastDotIndex, prefix, suffix, bytesAdded, blocking;
currReqBase = $.extend( { 'version': formatVersionNumber( maxVersion ) }, reqBase );
currReqBaseLength = $.param( currReqBase ).length;
currReqBase = $.extend( { 'version': formatVersionNumber( maxVersion ) }, reqBase );
currReqBaseLength = $.param( currReqBase ).length;
// We may need to split up the request to honor the query string length limit,
// so build it piece by piece.
l = currReqBaseLength + 9; // '&modules='.length == 9
// We may need to split up the request to honor the query string length limit,
// so build it piece by piece.
l = currReqBaseLength + 9; // '&modules='.length == 9
if ( maxQueryLength > 0 && !$.isEmptyObject( moduleMap ) && l + bytesAdded > maxQueryLength ) {
// This request would become too long, create a new one
// and fire off the old one
if ( maxQueryLength > 0 && !$.isEmptyObject( moduleMap ) && l + bytesAdded > maxQueryLength ) {
// This request would become too long, create a new one
// and fire off the old one
- doRequest( moduleMap, currReqBase, sourceLoadScript );
+ doRequest( moduleMap, currReqBase, sourceLoadScript, blocking );
l = currReqBaseLength + 9;
}
if ( moduleMap[prefix] === undefined ) {
moduleMap[prefix] = [];
}
moduleMap[prefix].push( suffix );
l = currReqBaseLength + 9;
}
if ( moduleMap[prefix] === undefined ) {
moduleMap[prefix] = [];
}
moduleMap[prefix].push( suffix );
+ if ( registry[modules[i]].blocking ) {
+ // If this module is blocking, make the entire request blocking
+ // This is slightly suboptimal, but in practice mixing of blocking
+ // and non-blocking modules will only occur in debug mode.
+ blocking = true;
+ }
l += bytesAdded;
}
// If there's anything left in moduleMap, request that too
if ( !$.isEmptyObject( moduleMap ) ) {
l += bytesAdded;
}
// If there's anything left in moduleMap, request that too
if ( !$.isEmptyObject( moduleMap ) ) {
- doRequest( moduleMap, currReqBase, sourceLoadScript );
+ doRequest( moduleMap, currReqBase, sourceLoadScript, blocking );
* @param type {String} 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 type {String} 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.
-
- /**
- * Enable or disable blocking. If blocking is enabled and
- * document ready has not yet occurred, scripts will be loaded
- * in a blocking way (using document.write) rather than
- * asynchronously using DOM manipulation
- *
- * @param b {Boolean} True to enable blocking, false to disable it
- */
- setBlocking: function( b ) {
- blocking = b;
- },