Remote scripts, especially ads, block the page from doing anything else while they load. They contribute a large % to load times which affects your bottom line. Asynchronous ads do not block the page and can be delivered after core content - Async FTW.
Why is it so hard to deliver ads asynchronously? Because they may contain calls to
document.write, which expects to be handled synchronously. PostScribe lets you deliver a synchronous ad asynchronously without modifying the ad code.
Shameless Plug: Using this standalone library is a great start, but if you want to go further and have your tags centrally managed instead of having them hard-coded on the page, Check out Krux's SuperTag, developed by the same authors as this library.
Other tag writing libraries exist (see alternatives), but PostScribe is novel in it's use of what we call DOM Proxies, a way to ensure that the content is written as close to the way the browser would natively write the content with
innerHTML. Read: it behaves just like the browser would, without convoluted parsing or hacks.
For more information:
PostScribe overrides document.write. It is best and safest to use PostScribe after DOM is ready.
./postscribe.js on your page. TODO: cdn for postscribe.min.js
To append html to #mydiv:
postscribe('#mydiv', '<h1>Hello PostScribe</h1>');
postscribe(element, html, options);
If you just want to mess around, include the js files at the top of an html page that contains the following:
Where normally you would have
Instead, remove the ad call and close the div
Wat? No. Only one tag writer at a time.
This project was originally developed at Krux as part of its SuperTag product. There it was battle tested on high-profile sites like The New York Times, The Wall Street Journal, NBCU, and hundreds of others. It is actively maintained by Krux.
Postscribe was designed to behave as closely to the native
innerHTML does as possible, and we've taken great care to make sure that it works on every browser we can get our hands on. We expect it to work on every browser built after 2005. There are over 400 unit tests that run on every commit, and we add more all the time. Postscribe is thoroughly tested and known to work well in the following browsers:
Curious if a specific browser will work? Run the tests yourself and let us know if you see any failures.
We've stood on the shoulders of giants with our work, and there are other alternative approaches to solve this problem. Shout out to the best ones we found:
If you would like your project to be added to this list, file an issue and we'd be happy to.
Have a problem? Need help? Would you like additional functionality added? We use github's ticket system for keeping track of these requests. Please check out the existing issues, and if you don't see that your problem is already being worked on, please file a new issue. The more information the better to describe your problem. We ♥ Jing bug reports.
We ♥ forks and pull requests.
To run the tests and static code analysis tools, you will need to have the following installed:
Spaces, not tabs. 2 of them. jQuery's style guide covers just about everything else. Please do not update 3rd-party libraries (qunit, jquery) or the dist directory. We have an internal process for doing this.
Please include a jsfiddle or plunker that distills and reproduces the issue. Try forking this jsfiddle. We've set everything up there for you so that you can reproduce your issue.
Using travis-ci and grunt, the Qunit unit tests are run on every commit using PhantomJS to run the tests with a real browser.
Current Build Status:
To run the tests:
$ grunt test
$ grunt lint
Pro Tip: You can use TDD and have jslint and the tests run on every commit with:
$ grunt watch
Postscribe uses software versioning standards as follows: major.new.maintenance[.trivial]. There are git tags for each release if you would like to see older versions.
Released on Oct 12 2012
We aim for you to use this inside your application, so we picked the least restrictive license we could find. MIT License - see LICENSE