Tuesday, December 10, 2019

Execution order of cache.js versus other script tags

My GWT code uses a an external javascript library through JsInterop and I want that library to download in parallel with my cache.js file, but execute before the cache.js file does. The problem is that the nocache.js injects the cache.js file into the page and any injected script tags are automatically loaded as async rather than defer, which means that if the cache.js file download finishes prior to the library, it will be executed first. Is there a way to download cache.js in parallel, but stop cache.js file from executing until other script tags have executed?

The code below is what I currently have. It guarantees that the execution order will correct, but the cache.js file won't even be injected and begin downloading until the library js file has downloaded and executed, which makes the page load much slower than if the cache.js file were downloaded in parallel with library.js.

<script defer src="library.js"></script>
<script defer src="myproject.nocache.js" ></script>

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/0ac16b61-ae9f-4484-974f-9b0288546f50%40googlegroups.com.

No comments:

Post a Comment