code: public static void whenReady(final String scriptname, final EventListener function) {
      List<EventListener> eventList = JsResources.eventLisenerQueue.get(scriptname);
      if (eventList == null) {
        eventList = new ArrayList<>();
        JsResources.eventLisenerQueue.put(scriptname, eventList);
      }
      eventList.add(function);
      if (BooleanUtils.isTrue(JsResources.initializationStarted.get(scriptname))
          || JsResources.isInHeader(scriptname)) {
        if (JsResources.isInitialized(scriptname)) {
          JsResources.eventLisenerQueue.get(scriptname)
              .forEach(action -> action.handleEvent(JsResources.rememberEvent.get(scriptname)));
          JsResources.eventLisenerQueue.get(scriptname).clear();
        }
        return;
      }
      JsResources.initializationStarted.put(scriptname, Boolean.TRUE);
  
      final ScriptElement jsScript = Browser.getDocument().createScriptElement();
      if (StringUtils.endsWith(scriptname, ".js")) {
        jsScript.setSrc(scriptname);
      } else {
        jsScript.setInnerHTML(scriptname);
      }
      jsScript.setType(JsResources.SCRIPT_TYPE);
  
      Browser.getDocument().getHead().appendChild(jsScript);
  
      jsScript.setOnload(event -> {
        JsResources.eventLisenerQueue.get(scriptname).forEach(action -> action.handleEvent(event));
        JsResources.eventLisenerQueue.get(scriptname).clear();
        JsResources.rememberEvent.put(scriptname, event);
      });
    }
docs: async load of resources.
  
  @param function function to call on load