The question is how to rewrite a static HTML script embedding:
<script async id="__script__id__"
type="text/javascript"
src="//abc.xyz.com/js/script.js">
</script>
into a programmatic embedding which allows loading the script only on a certain condition.
The bounty is set for a description of how static/programmatic embedding differ from one another, specifically:
- Explain how JS specification treats programmatically added scripts — when they are loaded and executed — with authoritative references.
- Explain how converting script embedding from HTML inline to programmatic affects browser optimizations (it's known that browser scans for HTML script tags with
srcattribute and preloads them) with authoritative references.