# Fix for black/white page flash when loading site with large file sizes

**URL:** <https://forum.readymag.com/t/fix-for-black-white-page-flash-when-loading-site-with-large-file-sizes/7235>\
**Category:** General topics\
**Created:** [October 12, 2026, 11:58am UTC](https://forum.readymag.com/t/fix-for-black-white-page-flash-when-loading-site-with-large-file-sizes/7235 "2026-10-12T11:58:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bundleofbees](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.readymag.com/bundleofbees/32/4713_2.png) [@bundleofbees](https://forum.readymag.com/u/bundleofbees)\
**Post date:** [October 12, 2026, 11:58am UTC](https://forum.readymag.com/t/fix-for-black-white-page-flash-when-loading-site-with-large-file-sizes/7235/1 "2026-10-12T11:58:28Z")

</div>

Hi all, I was having an issue with my site showing a black flash or white flash when loading and I’m pretty sure it’s due to the large amount of content on my site. I found a solution [from this linked post](https://forum.readymag.com/t/how-to-remove-white-flash-between-pages-in-readymag-solved-2025/5719) but had an issue where it would apply to the homepage, but not other pages and they’d would still have the flash before loading. I attached the code I used for my site that got rid of the flash on all pages of the site, hope it’s helpful.

HEAD CODE

```auto
<style>
  html, body {
    background-color: #fefefe !important;
  }

  #aka-preloader {
    position: fixed;
    inset: 0;
    background: #fefefe;
    z-index: 99999;
    opacity: 1;
    pointer-events: none;
    transition: none; /* showing is instant */
  }

  #aka-preloader.is-hidden {
    opacity: 0;
    transition: opacity .5s cubic-bezier(.4, 0, .2, 1); /* hiding fades */
  }
</style>

```

Before code:

```auto
<div id="aka-preloader"></div>

<script>
(function () {
  var p = document.getElementById('aka-preloader');
  if (!p) return;

  var cancelPending = null;

  function show() {
    if (cancelPending) cancelPending();
    p.classList.remove('is-hidden');
    hideWhenSettled();
  }

  // Hide once the page has stopped changing (or after 2.5s max)
  function hideWhenSettled() {
    var quiet, obs;
    var max = setTimeout(done, 2500);

    function done() {
      cancelPending && cancelPending();
      p.classList.add('is-hidden');
    }
    function reset() {
      clearTimeout(quiet);
      quiet = setTimeout(done, 350);
    }

    obs = new MutationObserver(reset);
    obs.observe(document.body, { childList: true, subtree: true });
    reset();

    cancelPending = function () {
      obs.disconnect();
      clearTimeout(quiet);
      clearTimeout(max);
      cancelPending = null;
    };
  }

  // First load
  if (document.readyState === 'complete') hideWhenSettled();
  else window.addEventListener('load', hideWhenSettled);

  // Catch every in-site navigation (links, menus, buttons)
  ['pushState', 'replaceState'].forEach(function (fn) {
    var orig = history[fn];
    history[fn] = function () {
      show();
      return orig.apply(this, arguments);
    };
  });
  window.addEventListener('popstate', show);
  window.addEventListener('hashchange', show);
})();
</script>

```

---

<div class="post-metadata">

**Author:** ![liamthompson](https://avatars.discourse-cdn.com/v4/letter/l/6bbea6/32.png) [@liamthompson](https://forum.readymag.com/u/liamthompson)\
**Post date:** [November 16, 2026, 12:00pm UTC](https://forum.readymag.com/t/fix-for-black-white-page-flash-when-loading-site-with-large-file-sizes/7235/2 "2026-11-16T12:00:59Z")

</div>

One edge case: the MutationObserver only watches childList changes under body. If a route change mainly updates attributes, canvas/WebGL state, or waits on images/fonts without adding nodes, the 350ms quiet timer won’t reset, so the preloader can fade while the new page is still settling. Observing a known app root with childList, subtree, and attributes, or waiting for a route-specific ready signal, would make the hide timing more reliable.
