How do I stop downloading js files?

for example, there is the following js code

var s = document.createElement("script")
s.src = "http://abc.com/dd.js"
s.id = "ak"
document.body.appendChild(s)

the above code will be loaded into dd.js,. What I want to ask is, assuming that dd.js has 1MB and the network environment I am in is also very slow, I want to terminate the download of this dd.js.
I found that ajax has an abort method to terminate the ajax request, but I couldn"t find the "abort" of js. I asked for great help.
ps: I tried to put s.srcroomnull. but found it useless, I will still download the dd.js file

.
May.10,2021

has given the download to the browser. Js cannot control the next behavior. The getScript implementation principle of jquery, learn


var script = document.createElement('script');
script.src = '//unpkg.com/console.img/dist/console.img.min.js';
document.body.appendChild(script);

setTimeout(() => {
  window.stop();
}, 300);

however, this will also cause all other resources to stop loading. The best way is to request once through ajax
if the load succeeds, then load it with the script tag

.
Menu