Load an external javascript library. The inserted script replaces the
element with the given id in the document.

@deprecated use {@link com.google.gwt.query.client.plugins.ajax.Ajax#loadScript(String)}
184046
@Deprecated
  public static void loadScript(String url, String id) {
    GQuery gs = GQuery.$(DOM.createElement("script"));
    GQuery gp = GQuery.$("#" + id).parent();
    if (gp.size() != 1) {
      gp = GQuery.$(GQuery.document.getBody());
    }
    GQuery.$("#" + id).remove();
    gp.append(gs.attr("src", url).attr("type", "text/javascript").attr("id", id));
  }
535348
private static void loadScript(ScriptEngine engine, Supplier<Reader> scriptReader) {

        try (Reader reader = scriptReader.get()) {
            engine.eval(reader);
        } catch (ScriptException | IOException e) {
            throw new RuntimeException(e);
        }

    }
1218156
@Override
  public Element setText(String script) {
    if (StringUtils.isEmpty(script)) {
      super.setText(script);
    }
    else {
      this.addContent(new Text("\n//"));

      // encapsulate script block in CDATA block
      this.addContent(new CDATA("\n"
          + script
          + "\n//"));

      this.addContent("\n");
    }
    return this;
  }
76546
public static void writeHtmlImagePreloadJavaScript(String url, Appendable out) throws IOException {
		out.append("<script type='text/javascript'>\n"
				+ "  var img=new Image();\n"
				+ "  img.src=\"");
		// Escape for javascript
		StringBuilder javascript = new StringBuilder(url.length());
		encodeTextInJavaScript(url, javascript);
		// Encode for XML attribute
		encodeJavaScriptInXhtmlAttribute(javascript, out);
		out.append("\";\n"
				+ "</script>");
	}
1130486
function loadPlugin(id) {
    var plugin = PLUGINS[id];
    plugin.exec.load(plugin.id, {
        id: plugin.id
    });
}
1240402
function load(js, resolver) {
        /*jshint newcap:false, evil:true*/
        // js is not a function
        if (!isFunction(js)) {
            if (isURL(js)) {
                appendScript(js, resolver);
                return;
            }
            if (supportDataURI) {
                // wraps up inline JavaScript into external script
                js = dataURIPrefix + encodeURIComponent(js);
                appendScript(js, resolver);
                return;
            }
        }

        var fn = isFunction(js) ? js : Function(js);

        // a synchronous function is wrapped into a special function
        // so that we could use the same logic as an asynchronous function
        if (!resolver.async) {
            var task = fn;
            fn = function (resolver) {
                try {
                    task.call(null);
                    resolver.resolve();
                }
                catch (e) {
                    resolver.reject(e);
                }
            };
        }

        loadFunction(fn, resolver);
    }
823913
protected Scriptable loadConfig(String configScript) throws IOException {
		configScript = processConfig(configScript);
		Context cx = Context.enter();
		Scriptable config;
		try {
			sharedScope = cx.initStandardObjects(null, true);

			// set up options object
			IOptions options = aggregator.getOptions();
			if (options != null) {
				optionsUpdated(options, 1);
			}
			// set up init params object
			InitParams initParams = aggregator.getInitParams();
			if (initParams != null) {
				Scriptable jsInitParams = cx.newObject(sharedScope);
				Collection<String> names = initParams.getNames();
				for (String name : names) {
					Collection<String> values = initParams.getValues(name);
					Object value = Context.javaToJS(values.toArray(new String[values.size()]), sharedScope);
					ScriptableObject.putProperty(jsInitParams, name, value);
				}
				ScriptableObject.putProperty(sharedScope, "initParams", jsInitParams); //$NON-NLS-1$
			}

			// set up bundle manifest headers property
			if ( aggregator.getPlatformServices() != null) {
				if( aggregator.getPlatformServices().getHeaders() != null){
					Dictionary<String, String> headers = (Dictionary<String, String>)( aggregator.getPlatformServices().getHeaders());
					Scriptable jsHeaders = cx.newObject(sharedScope);
					Enumeration<String> keys = headers.keys();
					while (keys.hasMoreElements()) {
						String key = keys.nextElement();
						Object value = Context.javaToJS(headers.get(key), sharedScope);
						ScriptableObject.putProperty(jsHeaders, key, value);
					}
					ScriptableObject.putProperty(sharedScope, "headers", jsHeaders); //$NON-NLS-1$
				}
			}

			// set up console object
			Console console = newConsole();
			Object jsConsole = Context.javaToJS(console, sharedScope);
			ScriptableObject.putProperty(sharedScope, "console", jsConsole); //$NON-NLS-1$
			GetPropertyFunction getPropertyFn = newGetPropertyFunction(sharedScope, aggregator);
			ScriptableObject.putProperty(sharedScope, "getProperty", getPropertyFn); //$NON-NLS-1$

			// Call the registered scope modifiers
			callConfigScopeModifiers(sharedScope);

			cx.evaluateString(sharedScope, "var config = " +  //$NON-NLS-1$
					aggregator.substituteProps(configScript, new IAggregator.SubstitutionTransformer() {
						@Override
						public String transform(String name, String value) {
							// escape forward slashes for javascript literals
							return value.replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$
						}
					}), getConfigUri().toString(), 1, null);
			config = (Scriptable)sharedScope.get("config", sharedScope); //$NON-NLS-1$
			if (config == Scriptable.NOT_FOUND) {
				throw new IllegalStateException("config is not defined."); //$NON-NLS-1$
			}
		} finally {
			Context.exit();
		}
		return config;
	}
409090
@Deprecated
  public Object f(com.google.gwt.user.client.Element e, int i) {
    setElement(e);
    setIndex(i);
    Widget w = GQuery.getAssociatedWidget(e);
    if (w != null) {
      f(w, i);
    } else {
      f(e.<com.google.gwt.dom.client.Element> cast());
    }
    return null;
  }
474136
public static void rebind(Element e) {
    EventsListener ret = getGQueryEventListener(e);
    if (ret != null) {
      DOM.setEventListener((com.google.gwt.user.client.Element) e, ret);
    }
  }
1102020
function loadHTML(url, id) {
  req = new XMLHttpRequest();
  req.open('GET', url);
  req.send();
  req.onload = () => {
    $id(id).innerHTML = req.responseText;
  };
}
46782
private StringBuffer loadScriptTemplate() {
		try (InputStream is = ClassLoaderResourceUtils.getResourceAsStream(SCRIPT_TEMPLATE, this);
				StringWriter sw = new StringWriter()) {
			IOUtils.copy(is, sw);
			return sw.getBuffer();

		} catch (IOException e) {
			Marker fatal = MarkerFactory.getMarker("FATAL");
			LOGGER.error(fatal, "a serious error occurred when initializing MessageBundleScriptCreator");
			throw new BundlingProcessException(
					"Classloading issues prevent loading the message template to be loaded. ", e);
		}
	}
364662
function insertScript (url) {
  const script = document.createElement('script')

  script.async = true
  script.src = url

  document.head.appendChild(script)

  return script
}
701527
protected void addScripts()
   {
      if (loadPlugins == null || loadPlugins.size() == 0)
      {
         return;
      }
      for (GroovyScript2RestLoaderPlugin loadPlugin : loadPlugins)
      {
         // If no one script configured then skip this item,
         // there is no reason to do anything.
         if (loadPlugin.getXMLConfigs().size() == 0)
         {
            continue;
         }

         Session session = null;
         try
         {
            ManageableRepository repository = repositoryService.getRepository(loadPlugin.getRepository());
            String workspace = loadPlugin.getWorkspace();
            session = repository.getSystemSession(workspace);
            String nodeName = loadPlugin.getNode();
            Node node = null;
            try
            {
               node = (Node)session.getItem(nodeName);
            }
            catch (PathNotFoundException e)
            {
               StringTokenizer tokens = new StringTokenizer(nodeName, "/");
               node = session.getRootNode();
               while (tokens.hasMoreTokens())
               {
                  String t = tokens.nextToken();
                  if (node.hasNode(t))
                  {
                     node = node.getNode(t);
                  }
                  else
                  {
                     node = node.addNode(t, "nt:folder");
                  }
               }
            }

            for (XMLGroovyScript2Rest xg : loadPlugin.getXMLConfigs())
            {
               String scriptName = xg.getName();
               if (node.hasNode(scriptName))
               {
                  LOG.debug("Script {} already created", scriptName);
                  continue;
               }

               createScript(node, scriptName, xg.isAutoload(), configurationManager.getInputStream(xg.getPath()));
            }
            session.save();
         }
         catch (Exception e)
         {
            LOG.error("Failed add scripts. ", e);
         }
         finally
         {
            if (session != null)
            {
               session.logout();
            }
         }
      }
   }
897377
@Override
	public Document loadHTML(Reader reader) {
		return loadHTML(reader, Charset.defaultCharset().name());
	}
269646
function loadScript(options, cb) {
  if (!options) {
    throw new Error('Can\'t load nothing...');
  }

  // Allow for the simplest case, just passing a `src` string.
  if (type(options) === 'string') {
    options = { src : options };
  }

  var https = document.location.protocol === 'https:' || document.location.protocol === 'chrome-extension:';

  // If you use protocol relative URLs, third-party scripts like Google
  // Analytics break when testing with `file:` so this fixes that.
  if (options.src && options.src.indexOf('//') === 0) {
    options.src = (https ? 'https:' : 'http:') + options.src;
  }

  // Allow them to pass in different URLs depending on the protocol.
  if (https && options.https) {
    options.src = options.https;
  } else if (!https && options.http) {
    options.src = options.http;
  }

  // Make the `<script>` element and insert it before the first script on the
  // page, which is guaranteed to exist since this Javascript is running.
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.async = true;
  script.src = options.src;

  // If we have a cb, attach event handlers. Does not work on < IE9 because
  // older browser versions don't register element.onerror
  if (type(cb) === 'function') {
    onload(script, cb);
  }

  tick(function() {
    // Append after event listeners are attached for IE.
    var firstScript = document.getElementsByTagName('script')[0];
    firstScript.parentNode.insertBefore(script, firstScript);
  });

  // Return the script element in case they want to do anything special, like
  // give it an ID or attributes.
  return script;
}
893135
function scriptLoader(url, callback) {

			var doc         = document, s = doc.createElement("script")
			  , head        = doc.getElementsByTagName("head")[0]
			  , node
			  , done        = false;
			;

			// On success listener
			function onScriptLoad() {
				if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") )
				{
					done     = true;
					callback();
				}
			}

			// On failure listener (callback receive an error false)
			function onScriptError() {
				callback(new Error("Packet loading error for " + url));
			}

			// Create the script tag
			node         = document.createElement('script')
			node.type    = config.scriptType || 'text/javascript';
			node.charset = 'utf-8';
			node.async   = true;

			// Listen to the onload event
			if (node.attachEvent &&
					!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0)) {
				node.attachEvent('onreadystatechange', onScriptLoad);
			} else {
				node.addEventListener('load', onScriptLoad, false);
				node.addEventListener('error', onScriptError, false);
			}

			// Set the src value with the packed script url
			node.src = url;

			// Start loading by adding the script tag in the head
			head.appendChild(node);

		}
911085
private String loadScript() throws CmdLineException, IOException, InterruptedException {
        if(script==null)
            throw new CmdLineException(null, "No script is specified");
        if (script.equals("="))
            return IOUtils.toString(stdin);

        checkChannel();
        return null; // never called
    }