Load IIFE in an External js File Upon Scene Unload?

(Quint Rahaman) #1

In an effort to control Hype document load time and document size, I would like to execute a call to load an external js file that contains an IIFE that houses an AJAX call to pull back a bit of data intended for use in the next scene. As such, I don’t want to make the call to the js file in the document HEAD. Is it possible to create a Hype function that will execute the requirements above upon scene unload (or anytime desired for that matter)?


If your talking about a Immediately Invoked Function Expression you can dynamically attach it to the document. But that isn’t a Hype specific function. Another question : Can you somehow define for the AJAX call a completion handler (best case)? or you could create a loop (timeline or setInterval) to check until the data is present and exit the loop once the data is loaded (workaround) to go to the next scene.

Here is a way to dynamically load a JS file (jQuery and vanilla)