code: public static Promise loadLink(final String rel, final String url) {
      GQuery link = $("link[rel='" + rel + "'][href^='" + url + "']");
      if (link.isEmpty()) {
        return new PromiseFunction() {
          public void f(final Deferred dfd) {
            GQuery link = $("<link rel='" + rel + "' href='" + url + "'/>");
            link.on("load", new Function() {
              public void f() {
                // load event is fired before the imported stuff has actually
                // being ready, we delay it to be sure it is ready.
                new Timer() {
                  public void run() {
                    dfd.resolve();
                  }
                }.schedule(100);
              }
            });
            $(document.getHead()).append(link);
          }
        };
      } else {
        return Deferred().resolve().promise();
      }
    }
docs: Load an external resource using the link tag element.
  It is appended to the head of the document.
  
  @param rel Specifies the relationship between the current document and the linked document.
  @param url Specifies the location of the linked document
  @return a Promise which will be resolved when the external resource has been loaded.