type="module" attribute makes sure that only modern browsers with
I had never come across a
<script> element with a
that was not linking to the URI of an external script and I was wondering if
this was some sort of hack. So I tried the following snippet.
const body = document.body;
body.style.backgroundColor = 'deeppink';
body.style.backgroundColor = 'purple';
// Uncaught ReferenceError: body is not defined
const body defined in the first module is available only in that module
and trying to use it in the second module results in an
Uncaught ReferenceError: body is not defined. So of course it is not a hack.
It is behaving exactly as you would expect.
The original website no longer exists 😔. Thankfully there's the Internet Archive. ↩︎