How to test if document.write() was successful
<p>I'm including some 3rd party code in my application and I see that it uses document.write() code which is wrapped in a try..catch statement. 
The document.write() doesn't return anything, so I wanted to know is there a way to test if document.write() was successful, so I can test catching the error. 
As an example, I tried including this script async but this stopped the document.write() part executing but it didnt run the code in the catch() part.</p>

<p>example code:</p>

<pre><code>try {
   document.write('&lt;script type="text/javascript" src="/plugin.js"&gt;');
   console.log('OK');
} catch (e) {
   console.log('ERROR');
}
</code></pre>
