Ti riporto lo scenario reale

codice:
$ tree├── index.html
├── resources
│   └── example.js
└── window-resources.js


$ cat index.html 
<html>
<head>
    <script type="text/javascript" src="window-resources.js"></script>
</head>
<body onload="open_window_resources()">


</body>
</html>


$ cat window-resources.js 
function open_window_resources() {
    const searchParams = new URLSearchParams(window.location.search);


    var script = document.createElement("script");
    var
        day = searchParams.has('day') ? searchParams.get('day') : new Date().getDate(),
        day2Digits = String(day).padStart(2, "0")
    ;


    script.src = "resources/" + searchParams.get("config_filename") + ".js";
    script.type = "text/javascript";
    script.async = false;


    setTimeout(() => {
        document.head.appendChild(script);
    }, 0);


    url_templates.forEach(
        function (template) {
            var url = template
                .replace("%1", day)
                .replace("%2", day2Digits)
            ;


            window.open(url);
        }
    );
}


$ cat resources/example.js 
var url_templates = new Array(
    "URL1",
    "URL2",
    "URL3",
);


$ xdg-open index.html?config_filename=example


Uncaught ReferenceError: url_templates is not defined
    at open_window_resources (window-resources.js:18:5)
    at onload (index.html?config_filename=example:5:40)
open_window_resources @ window-resources.js:18
onload @ index.html?config_filename=example:5