Why not just attach this JS via the page header settings? Either as a page attachment or a snippet in the head code section?
Blocs 3 has a code widget which is a step up from the html widget, basically it can handle any type of code as it prevents rendering code in the design environment which stops the code being effected by the canvas dom rendering and being executed. It’s a big improvement for JS and PHP.