diff --git a/localization.js b/localization.js index f30f814c..e5104ed7 100644 --- a/localization.js +++ b/localization.js @@ -66,17 +66,26 @@ function tNodeList(nodes) { function tDocLoader() { // localize HEAD - tNodeList(document.querySelectorAll("*")); + tNodeList(document.all); // localize BODY - var observer = new MutationObserver(function(mutations) { + const observer = new MutationObserver(function(mutations) { for (var m = 0; m < mutations.length; m++) { tNodeList(mutations[m].addedNodes); } }); - observer.observe(document, {subtree: true, childList: true}); - document.addEventListener("DOMContentLoaded", function() { + + const onLoad = () => { + tDocLoader.stop(); + tNodeList(document.all); + }; + tDocLoader.start = () => { + observer.observe(document, {subtree: true, childList: true}); + }; + tDocLoader.stop = () => { observer.disconnect(); - tNodeList(document.querySelectorAll("*")); - }); + document.removeEventListener('DOMContentLoaded', onLoad); + }; + tDocLoader.start(); + document.addEventListener('DOMContentLoaded', onLoad); } diff --git a/manage.js b/manage.js index d1ae1833..69713813 100644 --- a/manage.js +++ b/manage.js @@ -70,6 +70,7 @@ function showStyles(styles = []) { .sort((a, b) => a.name < b.name ? -1 : a.name == b.name ? 0 : 1); const shouldRenderAll = history.state && history.state.scrollY > innerHeight; const renderBin = document.createDocumentFragment(); + tDocLoader.stop(); renderStyles(0); // TODO: remember how many styles fit one page to display just that portion first next time function renderStyles(index) {