GWT library with external Javascript script

I wrote a GWT library for the javascript visualization library ( dygraphs ).
This is a simple wrapper using JavascriptObject and JSNI to call dygraphs code.
So far, I have included the dygraphs.js script in my GWT module XML file, and it worked just fine.

However, when I recently tried to use SuperDevMode , I had to switch to an xsiframe linker , which does not allow script tags.
What is the best practice of including external javascript scripts in the GWT library with cross-site linker?

The best I could come up with is to include the Javascript file as a TextResource in the ClientBundle and then use the ScriptInjector to enable it?

Is this a recommended approach or is there a better way?

I have to make sure dygraphs.js is fully loaded before my application using my GWT wrapper gets access to it.

+4
source share
1 answer

Including your external javascript as a text source and embedding it is a very good way to make sure it is loaded by your application. (and you save an additional HTTP request when using the GWT caching mechanism)

If you are running a thin client, you might want to separate the actual injection into the DOM from the parsing, which you could easily do if you enter a text source with comments from top to bottom and then delete it later.

+1
source

Source: https://habr.com/ru/post/1437995/


All Articles