I'm happy to announce the beta release of Write Capture 2. It's a
complete rewrite of Write Capture that simulates document.write rather
than capturing and post processing the output. While it's impossible
to replicate 100% of document.write's quirks, I think it should
eventually be more compatible with scripts than the current Write
Capture.
Please check it out here and report any bugs you find:
https://github.com/iamnoah/writeCapture/tree/writeCapture2
You'll also need to include element.write.js, which can be found in
the lib directory.
Advantages:
1. DOM elements are generally available immediately. That means no more hacks!
2. No jQuery or nolib support required!
Differences (may be good or bad):
1. The API is very different:
elementWrite.toElement(document.getElementById('id')).write(html).close();
// very important that you call close
2. All script tags now load and execute asynchronously. That will
generally mean a more responsive UI.
Known Edge Case:
1. document.written script tags will execute asynchronously, so they
wont be immediately available to the writing script. This sort of
dependency is rather perverse and should be rare (I'm not even sure it
would work cross browser). Unfortunately, it's impossible to block a
script being executed while we load and execute another script, so if
you hit this limitation, you'll have to work with your ad server or
use an iframe.
Cheers,
Noah