Script Element With Async Attribute Still Block Browser Render?
Solution 1:
The execution of any script always blocks parsing, rendering, and execution of other scripts in the same tab. The attribute async
does not change that.
The only thing async
does is tell the browser that the script should be fetched (assuming it's a remote file) without blocking those activities.
After the script is downloaded, the script starts executing at the next available opportunity (that is, right after the current script, if any, finishes running; a new script won't, of course, interrupt a running script). Once that happens, your rendering is blocked. So, with a fast web server, downloading happens so fast that async
makes no difference at all.
If you don't want your scripts to pause rendering, use defer
attribute instead of async
. That will delay the execution of the script until after the document is fully loaded.
Post a Comment for "Script Element With Async Attribute Still Block Browser Render?"