I have this peace of JS code:
// url = some url that return 200 or 403/404 status code
function f1() {
let script = document.createElement('script')
script.src = url;
script.onload = () => console.log("onload triggered");
script.onerror = () => console.log("onerror triggered");
document.head.appendChild(script)
}
f1();
I need an alternative way to trigger load and error events with no .onload and .onerror strings.
Any ideas?