On the article How, When, And Why Script Loaders Are Appropriate, I found the following comment without a clear explanation:
// Very simple asynchronous script-loader
// Create a new script element
var script = document.createElement('script');
// Find an existing script element on the page (usually the one this code is in)
var firstScript = document.getElementsByTagName('script')[0];
// Set the location of the script
script.src = "http://example.com/myscript.min.js";
// Inject with insertBefore to avoid appendChild errors
firstScript.parentNode.insertBefore( script, firstScript );
What errors they are avoiding by using insertBefore instead of appendChild?
Why would appendChild cause any errors?