Sugarcube does that ("incorporating" the whole js code), if you tell it to. You can also set it to link an external js file or library. However, as I am also experiencing in my own project, sometimes there are issues since the loading is async. It can happen that SC already displays a page, but without having fully loaded the code it references, which ends up in errors.
With this specific situation, my "professional advice" would be to load the code externally, with the importScripts function. It would probably result in a less bloated html file. I have recently setup mine to also minify the resulting js code and it seems to be working well.