From 15e195a177d828c300bb37f2508a88b087b52eb1 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 29 Jan 2018 15:30:23 -0800 Subject: [PATCH] resourceloader: Add minified version of mw.loader.implement() wrapper Follows-up b7eb243d92, which changed minification to be per-module, but had as result that the little implement() wrapper is not always minified, e.g. when outputting modules that have minification disabled (such as 'user.tokens' and 'user.options'). Rather than introducing some complex minification cache for the wrapper (with a find and replace for the variable content), simply add a hardcoded minified version of the wrapper. Change-Id: Iccf0d3408beab4387031cc55689394ff67e1e64b --- includes/resourceloader/ResourceLoader.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 36bf6567b9..ef26d1eb1d 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -1227,7 +1227,11 @@ MESSAGE; $name, $scripts, $styles, $messages, $templates ) { if ( $scripts instanceof XmlJsCode ) { - $scripts = new XmlJsCode( "function ( $, jQuery, require, module ) {\n{$scripts->value}\n}" ); + if ( self::inDebugMode() ) { + $scripts = new XmlJsCode( "function ( $, jQuery, require, module ) {\n{$scripts->value}\n}" ); + } else { + $scripts = new XmlJsCode( 'function($,jQuery,require,module){'. $scripts->value . '}' ); + } } elseif ( !is_string( $scripts ) && !is_array( $scripts ) ) { throw new MWException( 'Invalid scripts error. Array of URLs or string of code expected.' ); } -- 2.20.1