Skip to content

Instantly share code, notes, and snippets.

View arunkp's full-sized avatar

Arun Rao arunkp

View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active March 1, 2025 05:48
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@javiersantos
javiersantos / currentChromeTab.js
Last active August 21, 2022 12:34
Get the current URL of the selected Chrome tab. Useful for Chrome/Chromium extensions.
/*
* Get the current URL of the selected Chrome tab. Call to getCurrent
* By Javier Santos
* https://gist.github.com/javiersantos/c3e9ae2adba72e898f99
*/
var currentURL;
chrome.tabs.query({'active': true, 'windowId': chrome.windows.WINDOW_ID_CURRENT},
function(tabs){