From 9e682a964ae4d3c2bc2b446d0f0045d5304c79f5 Mon Sep 17 00:00:00 2001 From: Adhityaa Date: Mon, 11 Jun 2018 14:18:32 +0530 Subject: [PATCH] commento.js: allow dynamic script loading --- frontend/js/commento.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/js/commento.js b/frontend/js/commento.js index 8e8187a..2990c7e 100644 --- a/frontend/js/commento.js +++ b/frontend/js/commento.js @@ -1273,7 +1273,12 @@ $(ID_LOGIN_BOX_EMAIL_INPUT).focus(); } + var mainExecuted = false; function main(callback) { + if (mainExecuted) + return; + mainExecuted = true; + root = $(ID_ROOT); loginBoxCreate(); @@ -1294,6 +1299,8 @@ }); } - document.addEventListener("DOMContentLoaded", main); + document.addEventListener("domready", main); + if (document.readyState == "interactive" || document.readyState == "complete") + main(); }(window, document));