It sounds like you know how to call a function, but need a
way to distribute the '<script src="myscripts.js"...' portion of
your code.
Currently I do this by adding the javascript file to baggage
(you did this) and then inserting the <script
src="myscripts.js"...' bits to my topic templates (.HTT files).
This works for my projects, though I don't know if it is applicable
to yours.
The contents of your external javascript file will need to
(likely) look something like: