6

I need to import a JS file that is hosted on another server and is not part of my application's assets.

How can I import it from within the component?

Eleeist
  • 6,891
  • 10
  • 50
  • 77
  • for efficiency and reliability, i would strongly recommend downloading the script and hosting it from your application or web server. – pstanton Nov 02 '12 at 08:57
  • The script is generted dynamically by external server so there is no way I can host it myself. – Eleeist Nov 02 '12 at 08:59

1 Answers1

7

I ended up setting up environmental JavaScriptSupport and calling importJavaScriptLibrary from within setupRender():

@Environmental
private JavaScriptSupport javaScriptSupport;

public void setupRender() {
    this.javaScriptSupport.importJavaScriptLibrary("URL-to-JS-file");
}
Eleeist
  • 6,891
  • 10
  • 50
  • 77