I have some JavaScript that I want to inject into the DOM when I load up a certain component that uses that script. The component exists in a few places in my app though so it is reasonable for a user to load that component multiple times in a session. Is there a way to prevent the ScriptInjector from loading the same script multiple times?
Important performance question: if I have already loaded a script, does calling inject() on the same script cause the browser to download it a second time or does it realize that it already has the script?
I know that I could create some global variable like FANCY_JS_SCRIPT_LOADED = false; and then in the onSuccess of the callback, call something like FANCY_JS_SCRIPT_LOADED = true; but this seems really, really... heavy-handed.
Docs: http://www.gwtproject.org/javadoc/latest/com/google/gwt/core/client/ScriptInjector.html