forked from hamcha/tghandbook
Run dom manips before adding to tree so we don't duplicate resource requests
This commit is contained in:
parent
404b74321b
commit
b498669487
1 changed files with 8 additions and 3 deletions
|
@ -53,15 +53,20 @@ async function loadPage(page: string, elem: HTMLElement) {
|
|||
await nextAnimationFrame();
|
||||
|
||||
// Set as HTML content and run HTML manipulations on it
|
||||
elem.innerHTML = html;
|
||||
const div = document.createElement("div");
|
||||
div.className = elem.className;
|
||||
div.innerHTML = html;
|
||||
|
||||
console.log(`${page}: processing`);
|
||||
processHTML(elem, page);
|
||||
processHTML(div, page);
|
||||
|
||||
// Save result to cache
|
||||
cache.set(key, elem.outerHTML, CURRENT_VERSION).then(() => {
|
||||
cache.set(key, div.outerHTML, CURRENT_VERSION).then(() => {
|
||||
console.log(`${page}: saved to cache`);
|
||||
});
|
||||
|
||||
elem.replaceWith(div);
|
||||
elem = div;
|
||||
} else {
|
||||
// Set cached content as HTML
|
||||
elem.outerHTML = html;
|
||||
|
|
Loading…
Reference in a new issue