 
   (componentDidMount [this]
     (go
-      (<! (load-external-script "/vendor/vexflow-min.js"))
-      (om/set-state! this {:ready true})
+      (<! (require-vexflow))
       (let [div (js/ReactDOM.findDOMNode this)]
         (render-score (om/props this) div))))
 

      (swap! scripts assoc path c)
      (gdom/append js/document.body script)
      c)))

(defn format-and-draw [ctx stave notes]
  (js/Vex.Flow.Formatter.FormatAndDraw ctx stave (clj->js notes)))


(defonce scripts (atom {}))

(defn load-external-script [path]
  (if-let [script (get @scripts path)]
    script
