diff --git a/Yesod/EmbeddedStatic/AngularJavascript.hs b/Yesod/EmbeddedStatic/AngularJavascript.hs
--- a/Yesod/EmbeddedStatic/AngularJavascript.hs
+++ b/Yesod/EmbeddedStatic/AngularJavascript.hs
@@ -150,17 +150,19 @@
               <> "));"
     mini fileCt
 
-develModule :: Bool -> String -> FilePath -> IO BL.ByteString
-develModule inclTempl name dir = do
+develModule :: Bool -> String -> Location -> FilePath -> IO BL.ByteString
+develModule inclTempl name loc dir = do
     (jsFiles, tmpls, deps) <- loadModule dir
     let files = if inclTempl then jsFiles ++ tmpls else jsFiles
 
     let script = [julius|
 (function() {
+    if (angular.isUndefined(window.yesod_devel_scripts)) {
+        window.yesod_devel_scripts = {};
+    }
     /* We want to defer bootstrap until all scripts are loaded */
     if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
         window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
-        window.yesod_devel_scripts = {};
         window.yesod_devel_check_loaded = function() {
             for (var key in window.yesod_devel_scripts) {
                 if (!window.yesod_devel_scripts[key]) {
@@ -177,8 +179,13 @@
     angular.module(#{toJSON name}, #{deps});
 
     /* Figure out the full path of the current script */
-    var scripts = document.getElementsByTagName("script"),
-        path = scripts[scripts.length - 1].src;
+    var scripts = document.getElementsByTagName("script"), path;
+    for (var i=0; i<scripts.length; i++) {
+      if (scripts[i].src.indexOf(#{toJSON loc})>=0) {
+        path = scripts[i].src;
+        break;
+      }
+    }
 
     /* Add a script tag for each file in the module */
     var files = #{toJSON files};
@@ -235,6 +242,7 @@
     , ebProductionContent = productionModule incTempl name dir mini
     , ebDevelReload = [| develModule ($(litE $ integerL $ if incTempl then 1 else 0) == (1 :: Integer))
                                      $(litE $ stringL name) 
+                                     $(litE $ stringL loc)
                                      $(litE $ stringL dir) |]
     , ebDevelExtraFiles = Just [| develExtraFiles (T.splitOn (T.pack "/") $ T.pack $(litE $ stringL loc))
                                                   $(litE $ stringL name)
diff --git a/test/AngularSpec.hs b/test/AngularSpec.hs
--- a/test/AngularSpec.hs
+++ b/test/AngularSpec.hs
@@ -85,7 +85,7 @@
     describe "Angular" $ do
         it "embeds a single module without templates" $ do
             maybe (return ()) assertFailure $ gtError ang1
-            assertDev ang1 "test/angular/mod1-dev.js.expected"
+            assertDev ang1 "test/angular/ang1-mod1-dev.js.expected"
             assertDevExtra ang1 ["a","b","c","def.js","a.js"] "application/javascript" "test/angular/mod1/a-dev.js.expected"
 
         it "embeds multiple modules without templates" $ do
@@ -93,8 +93,8 @@
                 [mod1, mod2] -> do
                     maybe (return ()) assertFailure $ gtError mod1
                     maybe (return ()) assertFailure $ gtError mod2
-                    assertDev mod1 "test/angular/mod1-dev.js.expected"
-                    assertDev mod2 "test/angular/mod2-dev.js.expected"
+                    assertDev mod1 "test/angular/ang2s-mod1-dev.js.expected"
+                    assertDev mod2 "test/angular/ang2s-mod2-dev.js.expected"
                     assertDevExtra mod1 ["angmod","mod1.js","a.js"] "application/javascript" "test/angular/mod1/a-dev.js.expected"
                     assertDevExtra mod2 ["angmod","mod2.js","ctrl.js"] "application/javascript" "test/angular/mod2/ctrl-dev.js.expected"
 
@@ -102,7 +102,7 @@
 
         it "embeds a module together with templates" $ do
             maybe (return ()) assertFailure $ gtError ang3
-            assertDev ang3 "test/angular/mod1-and-templ-dev.js.expected"
+            assertDev ang3 "test/angular/ang3-mod1-and-templ-dev.js.expected"
             assertDevExtra ang3 ["module1.js", "my-tabs.hamlet"] "application/javascript" "test/angular/mod1/my-tabs-dev.js.expected"
 
         it "embeds multiple modules together with templates" $ do
@@ -110,8 +110,8 @@
                 [mod1, mod2] -> do
                     maybe (return ()) assertFailure $ gtError mod1
                     maybe (return ()) assertFailure $ gtError mod2
-                    assertDev mod1 "test/angular/mod1-and-templ-dev.js.expected"
-                    assertDev mod2 "test/angular/mod2-dev.js.expected"
+                    assertDev mod1 "test/angular/ang4s-mod1-and-templ-dev.js.expected"
+                    assertDev mod2 "test/angular/ang4s-mod2-dev.js.expected"
                     assertDevExtra mod1 ["xxx","mod1.js","my-tabs.hamlet"] "application/javascript" "test/angular/mod1/my-tabs-dev.js.expected"
                     assertDevExtra mod2 ["xxx","mod2.js","ctrl.js"] "application/javascript" "test/angular/mod2/ctrl-dev.js.expected"
 
diff --git a/test/angular/ang1-mod1-dev.js.expected b/test/angular/ang1-mod1-dev.js.expected
new file mode 100644
--- /dev/null
+++ b/test/angular/ang1-mod1-dev.js.expected
@@ -0,0 +1,45 @@
+
+(function() {
+    if (angular.isUndefined(window.yesod_devel_scripts)) {
+        window.yesod_devel_scripts = {};
+    }
+    /* We want to defer bootstrap until all scripts are loaded */
+    if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
+        window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
+        window.yesod_devel_check_loaded = function() {
+            for (var key in window.yesod_devel_scripts) {
+                if (!window.yesod_devel_scripts[key]) {
+                    /* Not loaded yet */
+                    return;
+                }
+            }
+            /* Everything has loaded, bootstrap can continue */
+            angular.resumeBootstrap();
+        };
+    }
+
+    /* Create the module */
+    angular.module("mod1", []);
+
+    /* Figure out the full path of the current script */
+    var scripts = document.getElementsByTagName("script"), path;
+    for (var i=0; i<scripts.length; i++) {
+      if (scripts[i].src.indexOf("a/b/c/def.js")>=0) {
+        path = scripts[i].src;
+        break;
+      }
+    }
+
+    /* Add a script tag for each file in the module */
+    var files = ["a.js","b.js","c.js","my-pane.js","my-tabs.js"];
+    for (var i = 0; i < files.length; i++) {
+        /* Add the script to the list of scripts to wait for */
+        window.yesod_devel_scripts["mod1" + "/" + files[i]] = false;
+
+        var s = document.createElement("script");
+        s.type = "application/javascript";
+        s.src = path + "/" + files[i];
+        document.body.appendChild(s);
+    }
+})();
+    
diff --git a/test/angular/ang2s-mod1-dev.js.expected b/test/angular/ang2s-mod1-dev.js.expected
new file mode 100644
--- /dev/null
+++ b/test/angular/ang2s-mod1-dev.js.expected
@@ -0,0 +1,45 @@
+
+(function() {
+    if (angular.isUndefined(window.yesod_devel_scripts)) {
+        window.yesod_devel_scripts = {};
+    }
+    /* We want to defer bootstrap until all scripts are loaded */
+    if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
+        window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
+        window.yesod_devel_check_loaded = function() {
+            for (var key in window.yesod_devel_scripts) {
+                if (!window.yesod_devel_scripts[key]) {
+                    /* Not loaded yet */
+                    return;
+                }
+            }
+            /* Everything has loaded, bootstrap can continue */
+            angular.resumeBootstrap();
+        };
+    }
+
+    /* Create the module */
+    angular.module("mod1", []);
+
+    /* Figure out the full path of the current script */
+    var scripts = document.getElementsByTagName("script"), path;
+    for (var i=0; i<scripts.length; i++) {
+      if (scripts[i].src.indexOf("angmod/mod1.js")>=0) {
+        path = scripts[i].src;
+        break;
+      }
+    }
+
+    /* Add a script tag for each file in the module */
+    var files = ["a.js","b.js","c.js","my-pane.js","my-tabs.js"];
+    for (var i = 0; i < files.length; i++) {
+        /* Add the script to the list of scripts to wait for */
+        window.yesod_devel_scripts["mod1" + "/" + files[i]] = false;
+
+        var s = document.createElement("script");
+        s.type = "application/javascript";
+        s.src = path + "/" + files[i];
+        document.body.appendChild(s);
+    }
+})();
+    
diff --git a/test/angular/ang2s-mod2-dev.js.expected b/test/angular/ang2s-mod2-dev.js.expected
new file mode 100644
--- /dev/null
+++ b/test/angular/ang2s-mod2-dev.js.expected
@@ -0,0 +1,45 @@
+
+(function() {
+    if (angular.isUndefined(window.yesod_devel_scripts)) {
+        window.yesod_devel_scripts = {};
+    }
+    /* We want to defer bootstrap until all scripts are loaded */
+    if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
+        window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
+        window.yesod_devel_check_loaded = function() {
+            for (var key in window.yesod_devel_scripts) {
+                if (!window.yesod_devel_scripts[key]) {
+                    /* Not loaded yet */
+                    return;
+                }
+            }
+            /* Everything has loaded, bootstrap can continue */
+            angular.resumeBootstrap();
+        };
+    }
+
+    /* Create the module */
+    angular.module("mod2", ["mod1"]);
+
+    /* Figure out the full path of the current script */
+    var scripts = document.getElementsByTagName("script"), path;
+    for (var i=0; i<scripts.length; i++) {
+      if (scripts[i].src.indexOf("angmod/mod2.js")>=0) {
+        path = scripts[i].src;
+        break;
+      }
+    }
+
+    /* Add a script tag for each file in the module */
+    var files = ["ctrl.js","factory.js"];
+    for (var i = 0; i < files.length; i++) {
+        /* Add the script to the list of scripts to wait for */
+        window.yesod_devel_scripts["mod2" + "/" + files[i]] = false;
+
+        var s = document.createElement("script");
+        s.type = "application/javascript";
+        s.src = path + "/" + files[i];
+        document.body.appendChild(s);
+    }
+})();
+    
diff --git a/test/angular/ang3-mod1-and-templ-dev.js.expected b/test/angular/ang3-mod1-and-templ-dev.js.expected
new file mode 100644
--- /dev/null
+++ b/test/angular/ang3-mod1-and-templ-dev.js.expected
@@ -0,0 +1,45 @@
+
+(function() {
+    if (angular.isUndefined(window.yesod_devel_scripts)) {
+        window.yesod_devel_scripts = {};
+    }
+    /* We want to defer bootstrap until all scripts are loaded */
+    if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
+        window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
+        window.yesod_devel_check_loaded = function() {
+            for (var key in window.yesod_devel_scripts) {
+                if (!window.yesod_devel_scripts[key]) {
+                    /* Not loaded yet */
+                    return;
+                }
+            }
+            /* Everything has loaded, bootstrap can continue */
+            angular.resumeBootstrap();
+        };
+    }
+
+    /* Create the module */
+    angular.module("mod1", []);
+
+    /* Figure out the full path of the current script */
+    var scripts = document.getElementsByTagName("script"), path;
+    for (var i=0; i<scripts.length; i++) {
+      if (scripts[i].src.indexOf("module1.js")>=0) {
+        path = scripts[i].src;
+        break;
+      }
+    }
+
+    /* Add a script tag for each file in the module */
+    var files = ["a.js","b.js","c.js","my-pane.js","my-tabs.js","my-pane.hamlet","my-tabs.hamlet"];
+    for (var i = 0; i < files.length; i++) {
+        /* Add the script to the list of scripts to wait for */
+        window.yesod_devel_scripts["mod1" + "/" + files[i]] = false;
+
+        var s = document.createElement("script");
+        s.type = "application/javascript";
+        s.src = path + "/" + files[i];
+        document.body.appendChild(s);
+    }
+})();
+    
diff --git a/test/angular/ang4s-mod1-and-templ-dev.js.expected b/test/angular/ang4s-mod1-and-templ-dev.js.expected
new file mode 100644
--- /dev/null
+++ b/test/angular/ang4s-mod1-and-templ-dev.js.expected
@@ -0,0 +1,45 @@
+
+(function() {
+    if (angular.isUndefined(window.yesod_devel_scripts)) {
+        window.yesod_devel_scripts = {};
+    }
+    /* We want to defer bootstrap until all scripts are loaded */
+    if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
+        window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
+        window.yesod_devel_check_loaded = function() {
+            for (var key in window.yesod_devel_scripts) {
+                if (!window.yesod_devel_scripts[key]) {
+                    /* Not loaded yet */
+                    return;
+                }
+            }
+            /* Everything has loaded, bootstrap can continue */
+            angular.resumeBootstrap();
+        };
+    }
+
+    /* Create the module */
+    angular.module("mod1", []);
+
+    /* Figure out the full path of the current script */
+    var scripts = document.getElementsByTagName("script"), path;
+    for (var i=0; i<scripts.length; i++) {
+      if (scripts[i].src.indexOf("xxx/mod1.js")>=0) {
+        path = scripts[i].src;
+        break;
+      }
+    }
+
+    /* Add a script tag for each file in the module */
+    var files = ["a.js","b.js","c.js","my-pane.js","my-tabs.js","my-pane.hamlet","my-tabs.hamlet"];
+    for (var i = 0; i < files.length; i++) {
+        /* Add the script to the list of scripts to wait for */
+        window.yesod_devel_scripts["mod1" + "/" + files[i]] = false;
+
+        var s = document.createElement("script");
+        s.type = "application/javascript";
+        s.src = path + "/" + files[i];
+        document.body.appendChild(s);
+    }
+})();
+    
diff --git a/test/angular/ang4s-mod2-dev.js.expected b/test/angular/ang4s-mod2-dev.js.expected
new file mode 100644
--- /dev/null
+++ b/test/angular/ang4s-mod2-dev.js.expected
@@ -0,0 +1,45 @@
+
+(function() {
+    if (angular.isUndefined(window.yesod_devel_scripts)) {
+        window.yesod_devel_scripts = {};
+    }
+    /* We want to defer bootstrap until all scripts are loaded */
+    if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
+        window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
+        window.yesod_devel_check_loaded = function() {
+            for (var key in window.yesod_devel_scripts) {
+                if (!window.yesod_devel_scripts[key]) {
+                    /* Not loaded yet */
+                    return;
+                }
+            }
+            /* Everything has loaded, bootstrap can continue */
+            angular.resumeBootstrap();
+        };
+    }
+
+    /* Create the module */
+    angular.module("mod2", ["mod1"]);
+
+    /* Figure out the full path of the current script */
+    var scripts = document.getElementsByTagName("script"), path;
+    for (var i=0; i<scripts.length; i++) {
+      if (scripts[i].src.indexOf("xxx/mod2.js")>=0) {
+        path = scripts[i].src;
+        break;
+      }
+    }
+
+    /* Add a script tag for each file in the module */
+    var files = ["ctrl.js","factory.js"];
+    for (var i = 0; i < files.length; i++) {
+        /* Add the script to the list of scripts to wait for */
+        window.yesod_devel_scripts["mod2" + "/" + files[i]] = false;
+
+        var s = document.createElement("script");
+        s.type = "application/javascript";
+        s.src = path + "/" + files[i];
+        document.body.appendChild(s);
+    }
+})();
+    
diff --git a/test/angular/mod1-and-templ-dev.js.expected b/test/angular/mod1-and-templ-dev.js.expected
deleted file mode 100644
--- a/test/angular/mod1-and-templ-dev.js.expected
+++ /dev/null
@@ -1,38 +0,0 @@
-
-(function() {
-    /* We want to defer bootstrap until all scripts are loaded */
-    if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
-        window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
-        window.yesod_devel_scripts = {};
-        window.yesod_devel_check_loaded = function() {
-            for (var key in window.yesod_devel_scripts) {
-                if (!window.yesod_devel_scripts[key]) {
-                    /* Not loaded yet */
-                    return;
-                }
-            }
-            /* Everything has loaded, bootstrap can continue */
-            angular.resumeBootstrap();
-        };
-    }
-
-    /* Create the module */
-    angular.module("mod1", []);
-
-    /* Figure out the full path of the current script */
-    var scripts = document.getElementsByTagName("script"),
-        path = scripts[scripts.length - 1].src;
-
-    /* Add a script tag for each file in the module */
-    var files = ["a.js","b.js","c.js","my-pane.js","my-tabs.js","my-pane.hamlet","my-tabs.hamlet"];
-    for (var i = 0; i < files.length; i++) {
-        /* Add the script to the list of scripts to wait for */
-        window.yesod_devel_scripts["mod1" + "/" + files[i]] = false;
-
-        var s = document.createElement("script");
-        s.type = "application/javascript";
-        s.src = path + "/" + files[i];
-        document.body.appendChild(s);
-    }
-})();
-    
diff --git a/test/angular/mod1-dev.js.expected b/test/angular/mod1-dev.js.expected
deleted file mode 100644
--- a/test/angular/mod1-dev.js.expected
+++ /dev/null
@@ -1,38 +0,0 @@
-
-(function() {
-    /* We want to defer bootstrap until all scripts are loaded */
-    if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
-        window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
-        window.yesod_devel_scripts = {};
-        window.yesod_devel_check_loaded = function() {
-            for (var key in window.yesod_devel_scripts) {
-                if (!window.yesod_devel_scripts[key]) {
-                    /* Not loaded yet */
-                    return;
-                }
-            }
-            /* Everything has loaded, bootstrap can continue */
-            angular.resumeBootstrap();
-        };
-    }
-
-    /* Create the module */
-    angular.module("mod1", []);
-
-    /* Figure out the full path of the current script */
-    var scripts = document.getElementsByTagName("script"),
-        path = scripts[scripts.length - 1].src;
-
-    /* Add a script tag for each file in the module */
-    var files = ["a.js","b.js","c.js","my-pane.js","my-tabs.js"];
-    for (var i = 0; i < files.length; i++) {
-        /* Add the script to the list of scripts to wait for */
-        window.yesod_devel_scripts["mod1" + "/" + files[i]] = false;
-
-        var s = document.createElement("script");
-        s.type = "application/javascript";
-        s.src = path + "/" + files[i];
-        document.body.appendChild(s);
-    }
-})();
-    
diff --git a/test/angular/mod2-dev.js.expected b/test/angular/mod2-dev.js.expected
deleted file mode 100644
--- a/test/angular/mod2-dev.js.expected
+++ /dev/null
@@ -1,38 +0,0 @@
-
-(function() {
-    /* We want to defer bootstrap until all scripts are loaded */
-    if (!/^NG_DEFER_BOOTSTRAP!/.test(window.name)) {
-        window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
-        window.yesod_devel_scripts = {};
-        window.yesod_devel_check_loaded = function() {
-            for (var key in window.yesod_devel_scripts) {
-                if (!window.yesod_devel_scripts[key]) {
-                    /* Not loaded yet */
-                    return;
-                }
-            }
-            /* Everything has loaded, bootstrap can continue */
-            angular.resumeBootstrap();
-        };
-    }
-
-    /* Create the module */
-    angular.module("mod2", ["mod1"]);
-
-    /* Figure out the full path of the current script */
-    var scripts = document.getElementsByTagName("script"),
-        path = scripts[scripts.length - 1].src;
-
-    /* Add a script tag for each file in the module */
-    var files = ["ctrl.js","factory.js"];
-    for (var i = 0; i < files.length; i++) {
-        /* Add the script to the list of scripts to wait for */
-        window.yesod_devel_scripts["mod2" + "/" + files[i]] = false;
-
-        var s = document.createElement("script");
-        s.type = "application/javascript";
-        s.src = path + "/" + files[i];
-        document.body.appendChild(s);
-    }
-})();
-    
diff --git a/yesod-static-angular.cabal b/yesod-static-angular.cabal
--- a/yesod-static-angular.cabal
+++ b/yesod-static-angular.cabal
@@ -1,5 +1,5 @@
 name:              yesod-static-angular
-version:           0.1.1
+version:           0.1.2
 cabal-version:     >= 1.8
 build-type:        Simple
 synopsis:          Yesod generators for embedding AngularJs code into yesod-static at compile time
