diff --git a/static/js/theme.js b/static/js/theme.js
index e868406832..4c9cbb6193 100644
--- a/static/js/theme.js
+++ b/static/js/theme.js
@@ -1478,6 +1478,14 @@ function updateTheme( detail ){
     }));
 }
 
+(function(){
+    window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
+        initChroma( true );
+        initMermaid( true );
+        initOpenapi( true );
+    });
+})();
+
 function useMermaid( config ){
     if( !Object.assign ){
         // We don't support Mermaid for IE11 anyways, so bail out early
@@ -1665,9 +1673,3 @@ ready( function(){
     moveTopbarButtons();
     adjustEmptyTopbarContents();
 })();
-
-(function(){
-    window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
-        initOpenapi( true );
-    });
-})();