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.
Other tag writing libraries exist (see alternatives), but PostScribe is novel in its 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:
document.write. It is best and safest to use PostScribe after DOM is ready.
If you just want to use the script without installing anything, use the following to load the script from cdnjs:
You can include
postscribe using npm:
npm install --save postscribe
You can include
postscribe using bower:
bower install --save postscribe
var postscribe = ;
To append html to #mydiv:
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
There are some hooks you may pass as the third argument. For example:
See the beginning of postscribe.js for a complete list.
No. Only one tag writer at a time.
This project was originally developed at Krux as part of its SuperTag product. There it has been 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 2009. There are over
500 unit tests that run on every commit. PostScribe is thoroughly tested and known to work well in the following browsers:
Note that we do not provide any support for Internet Explorer versions earlier than IE8.
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.
We ♥ bug reports.
Have a problem? Need help? Would you like additional functionality added? We use GitHub's ticket system for keeping track of these requests.
We ♥ forks and pull requests.
Please see CONTRIBUTING.md for full details.
The project requires nodejs (>=5.6) and npm (>=3.6.0) for development. It has no runtime dependencies.
Check the code out and install the development dependencies using:
To build the code, run
npm run build
npm run lint
Using travis-ci, the unit tests are run on every commit using PhantomJS to run the tests with a real browser.
To test the code locally, you can use:
To run tests in Test-Driven-Development mode, where the test will be run after every change, use:
npm run tdd
To run the cross-browser tests, use:
npm run test:cross-browser
Try forking this jsfiddle. We've set everything up there for you so that you can reproduce your issue.
We aim for you to use this inside your application, so we picked the least restrictive license we could find.