Skip to content

Instantly share code, notes, and snippets.

Avatar

Jinzhou Zhang lotabout

View GitHub Profile
@lotabout
lotabout / what-forces-layout.md
Created Aug 10, 2016 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

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()
@lotabout
lotabout / colors.sh
Last active Jan 15, 2016 — forked from cyrilis/colors.sh
A ImageMagick Script Can Generate Color Palettes JSON Format.Usage: ./colors.sh IMAGE-PATH COLOR-NUMBERS eg: ./colors.sh /Users/Cyril/Downloads/photo2.jpg 10
View colors.sh
dir="." #Set the default temp dir
tmpA1="$dir/spectrumhist_1_$$.png"
tmpB1="$dir/spectrumhist_1_$$.cache"
trap "rm -f $tmpA1 $tmpB1; exit 0" 0 #remove temp files
trap "rm -f $tmpA1 $tmpB1; exit 1" 1 2 3 15 #remove temp files
if [ $# -eq 2 ]
then
colors=$2
else
colors=8