Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

thewritestuff -- v0.9 (stable, but not sane)


Widget developers are a rather inconsiderate lot. They do fun things like ... say ... ask you to drop script tags that use 'document.write' to do things like .... say ... recursively drop script tags that also use 'document.write'. All of this pretty much adds up to your pages, becoming severely un-fast, severely unreliable and severely unflexible.

Yes, but that's the way it is ...

About 2 years ago, we got pretty frustrated hearing ourselves apologize for the mistakes of inconsiderate developers, and decided to solve the problem outright.

The result is thewritestuff.js, which overrides the document.write method on page load.

You Monkey-Patch document.write?!

Yes, on the window onLoad event, at which point the document.write method is non-operable. So, this doesn't break any existing functionality, in any browser. It merely allows you to render code with document.write in it post page load.

How To Use thewritestuff

<script type="text/javascript" src="/js/thewritestuff-min.js"></script>
<div id="target"><!-- --></div>
<script type="text/javascript">
    // feel free to use whatever event handlers you use, Writes just
    // happens to come with a simplified version of prototype.js's
    Writes.observe(window, 'load', function() {
        Writes.waitingToWrite.push(function() {
            document.write.apply(['<script type="text/javascript" src=""></script>'], document.getElementById('target'));
        // this will force onFinish to call and write the above ...
        // the interface here is terrible ... sorry.

Yes, but this is hideous code ...

We agree! Please help us make it better by forking it. If we all stand together, we can make inconsiderate widgetists irrelivant through spectacular feats of frustation.


thewritestuff.js sets 2 attributes on the window object (e.g. global namespace):

  • Writes (helper object, keeps track of the progress of your recursive writes)
  • Write (class constructor, instantiated by document.write post-page load)


None. We don't like the thought of having to use 160K+ of "core utilities" to get something simple working, and we didn't think you'd like that either.


  • No way to consistantly register writes, without introducing a race-condition, outside of pushing to 'waitingToWrite', followed by a document.write(''). This is such bad interface that it should be considered a bug.


Borrows liberally from Sam Stephenson's prototype.js


BSD, Copyright: © 2011, Tablet, Inc


a hack for poorly behaved widgets (push document.write off page-load).




No packages published
You can’t perform that action at this time.