This is needed for mobile scripts that are supposed to work on dumb
devices and as such can't rely on client-side RL, but still can take
advantage of server-side minification and concatenation.
Patchset 2: Allow loading raw modules with &raw=true appended to URL.
Change-Id: I9410ffbf6633075e07bd06b10a98a4d12d9b6106
foreach ( $modules as $name => $module ) {
/**
* @var $module ResourceLoaderModule
foreach ( $modules as $name => $module ) {
/**
* @var $module ResourceLoaderModule
$missing[] = $name;
unset( $modules[$name] );
}
$missing[] = $name;
unset( $modules[$name] );
}
+ $isRaw |= $module->isRaw();
wfProfileOut( __METHOD__ . '-' . $name );
}
// Update module states
wfProfileOut( __METHOD__ . '-' . $name );
}
// Update module states
- if ( $context->shouldIncludeScripts() ) {
+ if ( $context->shouldIncludeScripts() && !$context->getRaw() && !$isRaw ) {
// Set the state of modules loaded as only scripts to ready
// Set the state of modules loaded as only scripts to ready
- if ( count( $modules ) && $context->getOnly() === 'scripts'
- && !isset( $modules['startup'] ) )
- {
+ if ( count( $modules ) && $context->getOnly() === 'scripts' ) {
$out .= self::makeLoaderStateScript(
array_fill_keys( array_keys( $modules ), 'ready' ) );
}
$out .= self::makeLoaderStateScript(
array_fill_keys( array_keys( $modules ), 'ready' ) );
}
protected $only;
protected $version;
protected $hash;
protected $only;
protected $version;
protected $hash;
$this->debug = $request->getFuzzyBool( 'debug', $wgResourceLoaderDebug );
$this->only = $request->getVal( 'only' );
$this->version = $request->getVal( 'version' );
$this->debug = $request->getFuzzyBool( 'debug', $wgResourceLoaderDebug );
$this->only = $request->getVal( 'only' );
$this->version = $request->getVal( 'version' );
+ $this->raw = $request->getFuzzyBool( 'raw' );
$skinnames = Skin::getSkinNames();
// If no skin is specified, or we don't recognize the skin, use the default skin
$skinnames = Skin::getSkinNames();
// If no skin is specified, or we don't recognize the skin, use the default skin
+ /**
+ * @return bool
+ */
+ public function getRaw() {
+ return $this->raw;
+ }
+
protected $position = 'bottom';
/** Boolean: Link to raw files in debug mode */
protected $debugRaw = true;
protected $position = 'bottom';
/** Boolean: Link to raw files in debug mode */
protected $debugRaw = true;
+ /** Boolean: Whether mw.loader.state() call should be omitted */
+ protected $raw = false;
/**
* Array: Cache for mtime
* @par Usage:
/**
* Array: Cache for mtime
* @par Usage:
break;
// Single booleans
case 'debugRaw':
break;
// Single booleans
case 'debugRaw':
$this->{$member} = (bool) $option;
break;
}
$this->{$member} = (bool) $option;
break;
}
return $this->dependencies;
}
return $this->dependencies;
}
+ /**
+ * @return bool
+ */
+ public function isRaw() {
+ return $this->raw;
+ }
+
/**
* Get the last modified timestamp of this module.
*
/**
* Get the last modified timestamp of this module.
*
+ /**
+ * Whether this module's JS expects to work without the client-side ResourceLoader module.
+ * Returning true from this function will prevent mw.loader.state() call from being
+ * appended to the bottom of the script.
+ *
+ * @return bool
+ */
+ public function isRaw() {
+ return false;
+ }
+
/**
* Get the loader JS for this module, if set.
*
/**
* Get the loader JS for this module, if set.
*
+ /**
+ * @return bool
+ */
+ public function isRaw() {
+ return true;
+ }
+
/**
* @param $context ResourceLoaderContext
* @return string
/**
* @param $context ResourceLoaderContext
* @return string