Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / what-forces-layout.md
Last active April 26, 2024 17:33
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
@henrik-muehe
henrik-muehe / Dockerfile
Created August 5, 2013 11:47
Allows installing the ubuntu "fuse" package without creating any devices. Used to install packages on docker which require fuse but do not actively use it.
...
# Fake a fuse install
RUN apt-get install libfuse2
RUN cd /tmp ; apt-get download fuse
RUN cd /tmp ; dpkg-deb -x fuse_* .
RUN cd /tmp ; dpkg-deb -e fuse_*
RUN cd /tmp ; rm fuse_*.deb
RUN cd /tmp ; echo -en '#!/bin/bash\nexit 0\n' > DEBIAN/postinst
RUN cd /tmp ; dpkg-deb -b . /fuse.deb
@nikreiman
nikreiman / gist:5458386
Last active July 16, 2020 17:50
A quick script to clean up Gerrit branches. I tend to have 1 branch per commit for Gerrit reviews, which means that after some time there are a ton of stale branches sitting around. This script examines all your branches, looking for ones which have a change-id that also exists in the current branch. If it has found such a commit, it prompts you…
function git-branch-current() {
printf "%s\n" $(git branch 2> /dev/null | grep -e ^* | tr -d "\* ")
}
function git-branch-cleanup() {
local currentBranch=$(git-branch-current)
local otherBranch=
for otherBranch in $(git branch | grep -v $currentBranch) ; do
printf "Branch %s:\n" "$otherBranch"
printf " HEAD commit is: %s\n" "$(git log --oneline -n 1 $otherBranch)"
@michaelcox
michaelcox / SpecRunner.js
Last active January 11, 2024 06:05
Browser Unit Testing with Backbone Mocha Chai and RequireJS
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'