--- a/dirbrowser/cdb_html.cpp
+++ b/dirbrowser/cdb_html.cpp
@@ -19,6 +19,9 @@
 #include <string>
 
 #include <QSettings>
+#ifdef USING_WEBENGINE
+#include <QLoggingCategory>
+#endif
 #include <libupnpp/upnpavutils.hxx>
 
 #include "HelperStructs/CSettingsStorage.h"
@@ -36,10 +39,9 @@
 // - The links passed to acceptNav.. have the host part 
 //   lowercased -> we change S0 to http://h/S0, not http://S0
 
-
 // The const part + the js we need for webengine. This is logically
 // const after initialization by the first constructor.
-static QString html_top_js;
+static QString const_html_top;
 
 // The const part + the js + changeable style, computed as needed.
 static QString html_top;
@@ -67,8 +69,9 @@
 
 void CDBrowser::init_HTML()
 {
+    if (const_html_top.isEmpty()) {
+        const_html_top = u8s2qs("<html><head>");
 #ifdef USING_WEBENGINE
-    if (html_top_js.isEmpty()) {
         QLoggingCategory("js").setEnabled(QtDebugMsg, true);
 #if !defined(Q_OS_MACOS) && !defined(Q_OS_MAC)
         QString jsfn = Helper::getSharePath() + "/cdbrowser/containerscript.js";
@@ -78,16 +81,14 @@
         QString js = "<script type=\"text/javascript\">\n";
         js += QString::fromUtf8(Helper::readFileToByteArray(jsfn));
         js += "</script>\n";
-        html_top_js = html_top + js;
-    }
-#else
-    html_top_js = html_top;
+        const_html_top += js;
 #endif
+    }
     setStyleSheet(CSettingsStorage::getInstance()->getPlayerStyle(), false);
 }
 
 // Insert style from on-disk config data to our static constant
-// top-of-page.  Computes html_top from the constant html_top_js
+// top-of-page.  Computes html_top from the constant const_html_top
 void CDBrowser::setStyleSheet(bool dark, bool redisplay)
 {
     QString cssfn = Helper::getCSSPath() + "cdbrowser.css";
@@ -105,7 +106,7 @@
     }
     cssdata +=  Helper::readFileToByteArray(cssfn);
 
-    html_top = html_top_js;
+    html_top = const_html_top;
     html_top += "<style>\n";
     html_top += cssdata;
     html_top += "</style>\n";