For my eye tracking demo I implemented “download JS library” in a very PsychoJS-conformant way. To check whether the library is actually initialized (which is a problem both in the jQuery approach and the PsychoJS approach), I check each frame whether the expected global (window.webgazer) is exposed. Once it is, the library is ready, and I finish the routine.