Tuesday, April 19, 2016

Asynchronous script and document.write

While trying to fix an issue with script.aculo.us I discovered that document.write doesn't work with asynchronous scripts (defer="defer" or async="async" script attributes). script.aculo.us was using that function in order piggy-back load other javascript files. For example, scriptaculous.js?load=effects,dragdrop where document.write will import effects.js and dragdrop.js. Unfortunately browsers will ignore it because it's detached from the document so they don't know where to place it or when to process it. My solution was manually load the javascript files that script.aculo.us needed.

No comments: