weavejester / hiccup

Fast library for rendering HTML in Clojure
http://weavejester.github.io/hiccup
Eclipse Public License 1.0
2.68k stars 174 forks source link

Feat/lazy html element #134

Closed erjoalgo closed 8 years ago

erjoalgo commented 8 years ago

This feature adds the ability to lazy-load html elements into the DOM.

(GET "/rand" []
        (let [sleep-time (rand-int 10000)]
          (Thread/sleep sleep-time)
          (printf "slept for %s\n" sleep-time)
          (str sleep-time)
          ))

   (GET "/lazy-test" []
        (->> #(hiccup.element/lazy-element
               "/rand"
               ;(hiccup.element/image loding-gif-url)
               )
             (repeatedly 10)
             hiccup.element/ordered-list
             html))

lazy-loading

weavejester commented 8 years ago

Thanks for the PR, but JavaScript and XHRs are beyond Hiccup's scope.

erjoalgo commented 8 years ago

That's fine, it makes sense to keep it focused. I needed this feature for a project and I found it useful for presenting slow-loading resources so I thought I'd share it but wasn't sure if it was within scope.