Code Monkey home page Code Monkey logo

personal-website's Issues

Investigate the effects of using a ResizeObverver for triggering the Tiles component when supported

These trigger events may be less performant than a native ResizeObserver, but likely not its polyfill.

// Trigger on page load
// - Won't have scrollbar which may cause a jump
// or subpixel issues (mitigated by `tileSize + 1`)
// initialRender();
// Trigger on window resized, zoomed, device rotated, moved to another screens, etc.
// - `requestAnimationFrame` delays the call by ~0.5ms on x6 slow down on a clean environment but may improve the performance when multiple resize events occur at once. This occurance is rare since `render()` is quicker than a layout reflow, which occurs after requesting the frame, but I still want to protect against this edge case.
// - I can't pinpoint any negative effects because the system must already be impacted to be noticable (e.g. large canvas, x6 CPU slowdown, no offscreencanvas, and a lot of other tabs in the same process), and even then V8 optimises the calls very quickly
// - Basically, the reflow from all of the responsive styles of other elements have a larger impact than this component
// If you have more information on the performance of this component, I'd love to chat :D
window.addEventListener("resize", () => requestAnimationFrame(renderHandoff));
// Trigger on DOM content loaded (interactive DOM, not all resources)
// - Allows scrollbar to be included in the calculations in most cases
if (document.readyState === "loading") {
// Loading hasn't finished yet
document.addEventListener("DOMContentLoaded", initialRender);
} else {
// `DOMContentLoaded` has already fired
initialRender();
}
// Tripper after all resources (fonts, styles, images) are loaded for the last initial paint
// - In case a layout update occurred after the first-to-the-punch `DOMContentLoaded`
if (document.readyState !== "complete") {
// Loading hasn't finished yet
window.addEventListener("load", renderHandoff);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.