I want to include a JS file in another JS file in pure JS, so without NPM or Yarn.
I do not use classes/modules, so how can I do this?
What I mean with Pure JS
Pure JS is JavaScript that you directly can include in your HTML, like so:
<script src="path/to/pure-js-file.js"></script>
What I tried
Here are my two files:
app.js
require('./components/navbar.js');
components/navbar.js
alert('Navbar component!');
But I get this error:
Uncaught ReferenceError: require is not defined
Because normal browsers don't know the require keyword.