code: public static void loadScriptDependencies(final JsArrayString dependencies, final JavaScriptObject callback) {
  
          if (dependencies.length() == 0) {
              return;
          }
          final Set<String> absoluteUris = new HashSet<String>();
          for (int i = 0; i < dependencies.length(); i++) {
              absoluteUris.add(WidgetUtil.getAbsoluteUrl(dependencies.get(i)));
          }
          // Listener that loads the next when one is completed
          ResourceLoadListener resourceLoadListener = new ResourceLoadListener() {
  
              @Override
              public void onError(ResourceLoadEvent event) {
  
                  CmsDebugLog.consoleLog(event.getResourceUrl() + " could not be loaded.");
                  // The show must go on
                  absoluteUris.remove(event.getResourceUrl());
                  if (absoluteUris.isEmpty()) {
                      Scheduler.get().scheduleDeferred(new ScheduledCommand() {
  
                          public void execute() {
  
                              callNativeFunction(callback);
                          }
                      });
                  }
  
              }
  
              @Override
              public void onLoad(ResourceLoadEvent event) {
  
                  absoluteUris.remove(event.getResourceUrl());
                  if (absoluteUris.isEmpty()) {
                      Scheduler.get().scheduleDeferred(new ScheduledCommand() {
  
                          public void execute() {
  
                              callNativeFunction(callback);
                          }
                      });
  
                  }
              }
          };
  
          ResourceLoader loader = ResourceLoader.get();
          for (int i = 0; i < dependencies.length(); i++) {
              String preloadUrl = dependencies.get(i);
              loader.loadScript(preloadUrl, resourceLoadListener);
          }
      }
docs: Loads JavaScript resources into the window context.<p>
  
  @param dependencies the dependencies to load
  @param callback the callback to execute once the resources are loaded