added document.when("ready", callback); behavior