Pass a variable to Javascript directly from <script> HTML tag

Yes this is possible. Instead of creating a site attribute we can use the dataset. This is made for custom (data-)attributes.

All you need to do now is give the script an ID and query your data.

HTML:

<script async src="script.js" data-site="test.com" id="myscript"></script>

JS:

const script = document.querySelector("#myscript");

console.log(script.dataset.site);

EDIT: without a querySelector

console.log(document.currentScript.dataset.site);

<script async src="https://example.com/lib.js" site="sitePath"></script>

and:

site = document.currentScript.getAttribute('site'); // sitePath