I have a page with a script tag in HEAD section:
<script src="somescript.js" type="text/javascript" async></script>
As it contains async attribute it loads asynchronously and browser parses the page without waiting for this script to be downloaded. Once downloaded, this script will execute, also asynchronously so browser can continue on parsing the page.
This script, once downloaded will perform some actions and inserts yet another script dynamically via something similar to this:
var a = document.createElement('script');
a.type = 'text/javascript';
a.src = 'http://domain/otherscript.js';
var elem_body = document.getElementsByTagName('body')[0];
elem_body.appendChild(a);
This new dynamically inserted script will also be executed asynchronously and again browser can continue on to other things, so parsing the page or executing other scripts as needed.
Now, my understanding is that this script, from beginning to the end of its execution will not block browser in any way. It will load, insert another script and execute completely asynchronously. DOMContentLoaded event will not be slow down at all.
Hoever, will this possibly delay firing of onload event? It seems to me that as this script would start when the page is almost parsed. Then it would request other scripts and onload event would be possibly delayed further waiting for this last script to do its thing.
Is my understanding correct?
EDIT
Added test at http://plnkr.co/edit/BCDPdgCjPeNUmLbf7wNR?p=preview and in Chrome it seems that it does delay onload event