Reputation: 35276
What is the difference of placing a Javascript (.js) library on before the GWT application nocache.js
and after nocache.js
in a GWT application which uses the JS library in JSNI methods.
Does it affect wether a JSNI method will be functional or not?
Upvotes: 1
Views: 56
Reputation: 6486
That really depends on when the JSNI method is loaded.
To be safe - always check to see if the JS lib you are using has been loaded. eg
public native static boolean isJqueryMethodLoaded(String method) /*-{
if ($wnd.jQuery && $wnd.jQuery[method]) {
return true;
} else {
return false;
}
}-*/;
(edited - thanks to the other answers for clarifying the load sequence)
Upvotes: 2
Reputation: 3048
Normal <script>
tag are blocking, but the GWT script tag is not, since it is fetched asynchronously (i.e., non-blocking). The onModuleLoad()
is called only when the body has been parsed (i.e., scripts have been fetched). Hence:
<script>
tags will always be loaded when onModuleLoad()
is called.Have a look at here.
Upvotes: 1
Reputation: 64541
onModuleLoad
is always called at or after DOMContentLoaded
, and this will always happen after your scripts have loaded (because they could do document.write()
), unless you loaded them with async
or defer
.
So, unless you load your "other JS" with async
or defer
, it really shouldn't matter in which order you load them, as onModuleLoad
should always be called after both are loaded.
Upvotes: 1