My solution is similar to the one of lolo above. However, I insert the HTML code via JavaScript’s document.write instead of using jQuery:
a.html:
<html>
<body>
<h1>Put your HTML content before insertion of b.js.</h1>
…
<script src=«b.js»></script>
…
<p>And whatever content you want afterwards.</p>
</body>
</html>
Alternatively for browsers that support template literals the following also works:
b.js:
document.write(`
<h1>Add your HTML code here</h1>
<p>Notice, you do not have to escape LF’s with a »,
like demonstrated in the above code listing.
</p>
`);