Cache dom before leaving the page, rather than right after loding

This way dynamically added dom (vis js) also gets cached.
Merge pull request #564 from artemave/better-dom-cache

push.js: cache dom before leaving the page, rather than right after loading it