Skip to content

Instantly share code, notes, and snippets.

@mathias
Last active August 29, 2015 13:57
Show Gist options
  • Save mathias/9436464 to your computer and use it in GitHub Desktop.
Save mathias/9436464 to your computer and use it in GitHub Desktop.
An on-ready handler for Hoplon pages; works but not the most elegant. (added .clj to filename to make gist syntax highlight)
(page "onready.html")
(defn doc-ready-handler []
;; do some stuff after page is loaded and ready
)
(defn on-ready [fn]
(aset js/document
"onreadystatechange"
(fn []
(let [ready-state (. js/document -readyState)]
(when (= "complete" ready-state)
(fn))))))
(html
(head
(on-ready doc-ready-handler))
(body))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment