I'm wondering if it wouldn't be easier to just use relative path.
`script.src = scriptBaseName;`
As the script file is written in the same directory than the html file.