Including javascript into an html file is easy, but is it possible to go the other way? If I have a test.html file
<html>
<head>
<script>
function helloWorld() { console.log("Hello World!"); }
</script>
</head>
<body>
<h1 id="test">TEST</h1>
</body>
</html>
I want to be able to include this html in javascript so that I can reference all of the DOM elements and javascript of my html file, i.e.
require("test.html");
var header = document.getElementById("test");
helloWorld();
This code obviously does not work. But I'd really like to find a way to include an html file in javascript as if it were the document object. Is this possible?