Is the script tag of appendChild executed asynchronously?

clipboard.png

clipboard.png
but an error, initNECaptcha undefined will be reported with the append tag.

is the script tag of append executed asynchronously?

Mar.22,2021

to answer your question first, is the script tag of append executed asynchronously? The answer is depending on the situation. It can be asynchronous. Default is Synchronize. But from your code, it looks like Synchronize.

so why does Synchronize cause your "asynchronous" illusion?

the reason is that the web IO operation that the browser requests to download js is asynchronous. When the code is downloaded and returned to the browser, without adding the asynchronous attribute, the browser will be blocked from rendering Synchronize execution. I just said that the network IO operation of requesting download js is asynchronous, so when the code requests to download the js file again, your initialization code has already been executed, so it is obvious that the code will report an error.

so to solve your problem, you need to write the initialization code into the script onLoad event .

I hope my answer will be helpful to you. My personal homepage is https://azl397985856.github.io/, and the Nuggets homepage https://juejin.im/user/58af98.

Menu