   (prn :requesting-reload (::track/load refresh-tracker))
   (eval-script repl-env
                (str "(function() {\n"
-                    "if(typeof goog.net.jsloader == 'undefined') {\n"
-                    "  throw new Error(\"Tire iron not initialized\");"
-                    "}\n"
-                    (when before
-                      (let [b (comp/munge before)]
-                        (str "if (typeof " b " !== 'undefined') {\n"
-                             "  " b ".call(null);\n"
-                             "} else {\n"
-                             "  throw new Error(\"Cannot resolve :before symbol: " b "\");\n"
-                             "}\n")))
-                    (when state
-                      (let [s (comp/munge state)]
-                        (str "if (typeof " s " !== 'undefined') {\n"
-                             "  goog.tire_iron_state_ = " s ";\n"
-                             "} else {\n"
-                             "  throw new Error(\"Cannot resolve :state symbol: " s "\");\n"
-                             "}\n")))
-                    (compile-unload-nss (::track/unload refresh-tracker))
-                    "var d = " (compile-load-nss (::track/load refresh-tracker)) ";\n"
-                    (str "d.addCallback(function(res) {\n"
-                         (when state
-                           (let [s (comp/munge state)]
-                             (str "if (typeof " s " !== 'undefined') {\n"
-                                  "  " s " = goog.tire_iron_state_;\n"
-                                  "} else {\n"
-                                  "  throw new Error(\"Cannot resolve :state symbol: " s "\");\n"
-                                  "}\n")))
-                         (when after
-                           (let [a (comp/munge after)]
-                             (str "if (typeof " a " !== 'undefined') {\n"
-                                  "  " a ".call(null);\n"
-                                  "} else {\n"
-                                  "  throw new Error(\"Cannot resolve :before symbol: " a "\");\n"
-                                  "}\n")))
-                         "})\n")
+                    (call-sym-script (comp/munge before))
+                    (set-ti-state-from-sym-script (comp/munge state))
+                    (unload-nss-script (map comp/munge
+                                            (::track/unload refresh-tracker)))
+                    "var d = " (load-nss-browser-async (map comp/munge
+                                                            (::track/load refresh-tracker)))
+                    ";\n"
+                    "d.addCallback(function(ret) {\n"
+                    (set-sym-from-ti-state-script (comp/munge state))
+                    (call-sym-script (comp/munge after))
+                    "  });\n"
                     "})();"))
   (alter-var-root #'refresh-tracker (fn [tracker]
                                       (assoc tracker

    (second symbol-or-list)
    symbol-or-list))

(defn disable-unload!
  ([ns]
   (alter-var-root #'disabled-unload-namespaces conj (maybe-quoted->symbol ns))))

(defn disable-reload!
  ([ns]
   (alter-var-root #'disabled-load-namespaces conj (maybe-quoted->symbol ns))))

(defn print-disabled []
  (prn "disabled unload" disabled-unload-namespaces)

         loaded-libs " = cljs.core.disj.call(null, " loaded-libs ", ns_string);\n"
         "})();")))

(defn unload-nss-script [nss]
  (str/join "\n"
            (map compile-unload-ns
                 nss)))

(defn load-nss-browser-async [nss]
  (let [loaded-libs (comp/munge 'cljs.core/*loaded-libs*)
        nss-array (str "["
                       (str/join ",\n"
                                 (map (comp #(str "goog.basePath + goog.dependencies_.nameToPath[\"" % "\"]")
                                            comp/munge)
                                      nss))
                       "]")]
    (str "(function() {\n"
         "var nss = " nss-array ";"
         "return goog.net.jsloader.loadMany(nss).addCallback(function() {"
         "  cljs.core.apply.call(null, cljs.core.conj, " loaded-libs ", nss);"
         "  });"
         "})();")))

(defn remove-disabled [tracker]
  (-> tracker
