+ /**
+ * Load a script by URL.
+ *
+ * Example:
+ *
+ * mw.loader.getScript(
+ * 'https://example.org/x-1.0.0.js'
+ * )
+ * .then( function () {
+ * // Script succeeded. You can use X now.
+ * }, function ( e ) {
+ * // Script failed. X is not avaiable
+ * mw.log.error( e.message ); // => "Failed to load script"
+ * } );
+ * } );
+ *
+ * @member mw.loader
+ * @param {string} url Script URL
+ * @return {jQuery.Promise} Resolved when the script is loaded
+ */
+ mw.loader.getScript = function ( url ) {
+ return $.ajax( url, { dataType: 'script', cache: true } )
+ .catch( function () {
+ throw new Error( 'Failed to load script' );
+ } );
+ };
+