Skip to content

Instantly share code, notes, and snippets.

View BruceWeng's full-sized avatar
🤓
Optimized for Change

Bruce Weng BruceWeng

🤓
Optimized for Change
  • LeanTaaS
  • San Francisco Bay Area
View GitHub Profile
@BruceWeng
BruceWeng / what-forces-layout.md
Created December 27, 2018 21:41 — forked from paulirish/what-forces-layout.md
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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@BruceWeng
BruceWeng / gist:96909b9f00f452e4e3655f1a28ea71ed
Created June 28, 2016 02:34 — forked from dburger/gist:1008320
Javascript Array Binary Heap
/*
array implementation of a binary heap, example usage:
// can optionally provide a comparison function, a function for a max
// heap is the default if no comparison function is provided
var bh = binaryHeap();
bh.push(5);
bh.push(34);
bh.push(16);
var max = bh.pop(); // 34
@BruceWeng
BruceWeng / misc.css
Last active August 29, 2015 14:22 — forked from askaidau/misc.css
/* basic reset */
html,body,p,ul,ol,dl,li,dt,dd,h1,h2,h3,h4,h5,h6 {
margin:0;padding:0;
}
html {
-webkit-text-size-adjust: none;
}
ul,ol {
list-style:none
}