Error when Loading External Library

I am trying to load an external script in order to use a morse code player to encode my question word and play it as morse audio for the purpose of learning morse code. My first line in the front template is:

The problem is, the first time I present a card, an error “Invalid HTML on Card” is thrown because the HTML below that line rendered before the external script finished loading. After the first card throws that error, subsequent cards render the morse player as I want. Is there a way to import the external library one time at the beginning of the session so I don’t have to do it every time I present a card? Or possibly there is a way to use JS onload with a function to do this? Thank you for your help!