Skip to content

Instantly share code, notes, and snippets.

@piecyk
Created July 9, 2025 09:03
Show Gist options
  • Select an option

  • Save piecyk/f0945f58ae8b4382c9983feafcbe9dcc to your computer and use it in GitHub Desktop.

Select an option

Save piecyk/f0945f58ae8b4382c9983feafcbe9dcc to your computer and use it in GitHub Desktop.
function waitForTimeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function waitForIdle(timeout = 2000) {
return new Promise(resolve => {
if ('requestIdleCallback' in window) {
requestIdleCallback(resolve, { timeout });
} else {
setTimeout(resolve, timeout);
}
});
}
const testList = async (offsetTop) => {
const scrollElement = document.querySelector(
'[aria-label="Grid table scroll wrapper"]'
);
if (!scrollElement) {
console.warn("Scroll element not found");
return;
}
console.log("πŸ“Œ Found scroll element:", scrollElement);
performance.clearMarks();
performance.clearMeasures();
performance.mark("scroll-start");
console.log("βœ… Marked scroll-start");
scrollElement.scrollTo({ top: offsetTop });
console.log("πŸŒ€ Scrolling...");
await waitForTimeout(100);
console.log("⏳ waitForTimeout complete");
await waitForIdle();
console.log("πŸ›οΈ waitForIdle complete");
performance.mark("scroll-end");
console.log("βœ… Marked scroll-end");
performance.measure("scroll", "scroll-start", "scroll-end");
const data = performance.getEntriesByName("scroll");
console.log("πŸ“Š Measured scroll performance:", data?.[0].duration);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment