Giter VIP home page Giter VIP logo

thewritestuff's Introduction

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

Why?

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="http://widgets.su.ck/widget.js"></script>'], document.getElementById('target'));
        });
        // this will force onFinish to call and write the above ...
        // the interface here is terrible ... sorry.
        document.write('');
    });
</script>

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.

Footprint

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)

Dependecies

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.

Bugs

  • 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.

Authors

Borrows liberally from Sam Stephenson's prototype.js

License

BSD, Copyright: © 2011, Tablet, Inc

thewritestuff's People

Stargazers

S avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.