Skip to content

Instantly share code, notes, and snippets.

@zehnpaard
Created September 22, 2016 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zehnpaard/e2e262cba2aa301b49b58ed556e36ce8 to your computer and use it in GitHub Desktop.
Save zehnpaard/e2e262cba2aa301b49b58ed556e36ce8 to your computer and use it in GitHub Desktop.
Function for dynamic reloading of css from clojurescript
;; Intended use: hot-loading changes to garden-generated css via figwheel
(defn load-css [css-text]
(let [current-style (js/document.getElementById "mystyle")]
(if current-style
(.removeChild (.-parentNode current-style) current-style)))
(let [new-style (js/document.createElement "style")]
(set! (.-id new-style) "mystyle")
(.appendChild new-style (js/document.createTextNode css-text))
(.appendChild (.-head js/document) new-style)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment