Here's another variation I've used when wanting to generate a script tag inline (so it executes immediately) without needing any form of escapes:
<script>
var script = document.createElement('script');
script.src = '/path/to/script.js';
document.write(script.outerHTML);
</script>
(Note: contrary to most examples on the net, I'm not setting type="text/javascript"
on neither the enclosing tag, nor the generated one: there is no browser not having that as the default, and so it is redundant, but will not hurt either, if you disagree).