If your imported external JavaScript code seems to not working, even though you used
script src="code.js">, you may forget about adding the ‘async’. You may add this attribute into your index.html like that:

spoiler

<script src=“code.js” async>

it may seem irrelevant, but sometimes little things like that may help :)