+ if ( $err ) {
+ // Send the error to the browser console client-side.
+ // By returning this as replacement for the actual script,
+ // we ensure modules are safe to load in a batch request,
+ // without causing other unrelated modules to break.
+ return 'mw.log.error(' .
+ Xml::encodeJsVar( 'JavaScript parse error: ' . $err->getMessage() ) .
+ ');';
+ }
+ return $contents;