Skip to content

[8822] Remove resize preloader #21

@rossjrw

Description

@rossjrw

8822 features a resize preloader that detects what possible resizes are upcoming and sends the request ahead of time, so that they're cached by the time that resize actually needs to be performed

this.currentTask = requestIdleCallback(async () => {
console.debug(`Preloading assertion state ${snapshot}`);
// Delay upfront so the real iframe gets priority
await new Promise((resolve) => setTimeout(resolve, 300));
await new Promise((resolve) => {
const preloadIframe = document.createElement("iframe");
this.frames.push({ snapshot, frame: preloadIframe });
preloadIframe.addEventListener("load", () => resolve());
// Iframe is fully sandboxed: allow-same-origin is implicitly false, prevents the controller being resized
preloadIframe.sandbox = true;
preloadIframe.classList.add("preload-iframe");
document
.getElementById("preload-container")
.appendChild(preloadIframe);
preloadIframe.src =
document.referrer +
"/common--javascript/resize-iframe.html?" +
"#" +
snapshotToSize(snapshot) +
"/" +
location.href.replace(/^.*\//, "/").replace(/^\/+/, "");
});

After discussion with @radian628, we found that the hash segment of the URLs are not being sent to the server anyway and are not involved in caching at all, rendering the preloader not only useless but actively harmful by sending unnecessary requests

https://github.com/scpwiki/interwiki/blob/main/js/resizeIframe.js does not do any cachebusting of its own so the preloader can literally just be removed

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions