Skip to content

Potential performance optimizations #40

@myfairsyer

Description

@myfairsyer

I neither faced any performance issues myself nor did I run extensive benchmarks on what I'm suggesting.

The points do not come from my personal experience either, some are even rather hearsay so take it with a grain of salt.

  1. During scrolling it looks like you j-query both the elements and the body just to use the jQuery methods .scrollTop() and .offset(). Vanilla JS might bring performance gains here.
  2. In recurse you also j-query each element and then use .css() to access their display style. Plain vanilla JSshould also be more performant here.
  3. In elementInViewport you walk up the parent chain. getBoundingClientRect() should usually be more performant.

I did see JSPerfs supporting these claims at least on my machine and current browser so I might (or might not) add them here later.

Again: I neither reviewed those JSPerfs, nor did I run them on multiple browsers or devices, nor did I performance-test in the context of your code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions