Import nodes not added as async in the DOM

I remember reading somewhere that if a tag is scriptadded DOMwith appendChild, it does not block and behaves as if it had an attribute async. Today I read this article and has the following code snippet:

var link = document.createElement('link');
link.rel = 'import';
link.href = 'file.html';
//link.setAttribute('async', ''); // make it async!

So, I am wondering if the behavior described for the tag scriptis the same for the tag link? Why add an attribute asyncmanually?

+4
source share
1 answer

, <link rel="import>, async, .

<link> appendChild(), script, , .

-with appendChild() - , async.

document.head.appendChild( link )
//link should be async if it uses the element below:
document.body.appendChild( element )
+1

Source: https://habr.com/ru/post/1662438/


All Articles