diff --git a/templates/footer.tpl b/templates/footer.tpl
index c9585cc..1b759db 100644
--- a/templates/footer.tpl
+++ b/templates/footer.tpl
@@ -17,21 +17,8 @@
 	</div>
 	<!-- ENDIF !isSpider -->
 
-
-	<script defer src="{relative_path}/assets/nodebb.min.js?{config.cache-buster}"></script>
-
-	<!-- BEGIN scripts -->
-	<script defer type="text/javascript" src="{scripts.src}"></script>
-	<!-- END scripts -->
-
 	<script>
-		window.addEventListener('load', function () {
-			require(['forum/footer']);
-
-			<!-- IF useCustomJS -->
-			{{customJS}}
-			<!-- ENDIF useCustomJS -->
-		});
+		require(['forum/footer']);
 	</script>
 
 	<div class="hide">
diff --git a/templates/header.tpl b/templates/header.tpl
index df5f18b..f8bf559 100644
--- a/templates/header.tpl
+++ b/templates/header.tpl
@@ -22,6 +22,16 @@
 	<!-- IF useCustomCSS -->
 	<style>{{customCSS}}</style>
 	<!-- END -->
+
+	<script src="{relative_path}/assets/nodebb.min.js?{config.cache-buster}"></script>
+	<!-- BEGIN scripts -->
+	<script type="text/javascript" src="{scripts.src}"></script>
+	<!-- END scripts -->
+	<!-- IF useCustomJS -->
+	<script>
+	{{customJS}}
+	</script>
+	<!-- ENDIF useCustomJS -->
 </head>
 
 <body class="{bodyClass} skin-{config.bootswatchSkin}">