← Commit history

Defer the README viewer load so its 15MB does not starve the wiki native 3D viewer's board.glb fetch

John Lauer ·c0c00627a5 ·2mo ago ·parent ea32855
1 file changed +19−9
README.html+19−9
@@ -299,16 +299,26 @@ Designed by Adom in Fort Worth, Texas. 2026-08-20.</p>   // click cannot reach it from outside the sandboxed frame either, so it was   // untestable. Deferring on visibility keeps the 15 MB off first paint   // without making the reader do anything.-  if (host && window.IntersectionObserver) {-    var io = new IntersectionObserver(function (entries) {-      for (var i = 0; i < entries.length; i++) {-        if (entries[i].isIntersecting) { io.disconnect(); loadViewer(); return; }-      }-    }, { rootMargin: '200px' });-    io.observe(host);-  } else {-    setTimeout(loadViewer, 1200);+  // Defer until the page has settled. The wiki renders its OWN native 3D+  // Model viewer above this README, and that fetches board.glb (~2.8 MB). If+  // this iframe starts pulling its 15 MB of bundle parts at the same time, the+  // native viewer's fetch is starved and it gives up with "Failed to load+  // model — taking too long". Let the page finish first, then load on view.+  function armViewerLoad() {+    if (!host) return;+    if (window.IntersectionObserver) {+      var io = new IntersectionObserver(function (entries) {+        for (var i = 0; i < entries.length; i++) {+          if (entries[i].isIntersecting) { io.disconnect(); loadViewer(); return; }+        }+      }, { rootMargin: '100px' });+      io.observe(host);+    } else {+      setTimeout(loadViewer, 1200);+    }   }+  if (document.readyState === 'complete') setTimeout(armViewerLoad, 2500);+  else addEventListener('load', function () { setTimeout(armViewerLoad, 2500); });   function post() {     var h = wrap.offsetHeight + 24;     if (h !== last) { last = h; parent.postMessage({ type: 'readme-height', height: h }, '*'); }