I am trying to load external script file only on a production mode.
At first, I tried to use NODE_ENV, but found it impossible.
So I compared URL using window.location.host as shown below.
Isn't there a more sophisticated way?
<!DOCTYPE html>
<html>
<head>
...
<script>
window.addEventListner('load', function(event) {
let host = window.location.host;
if (host.match('some production URL')) {
var script = document.createElement('script');
script.setAttribute('src', '~.js');
document.head.appendChild(script);
}
</script>
</head>
<body>
</div id="app></div>
</body>
</html>