Create juniper.js

PhamtonJs is a headless WebKit with JavaScript API. When crawling a page, PhatomJs will download all dependant requests such as images, js, css... It will also executes JS and ajax calls. However the onLoaded callback is invoked when the page finishes the loading, not when there are no pending requests. So, you have to use a trick for this.
There are two way to solve the problem :
Wait until "something" effectively changed in you page (an element). The best example is waitFor.js
Or
Wait a few seconds until no requests were received.