Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / what-forces-layout.md
Last active August 15, 2025 09:34
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
@kvetis
kvetis / README.md
Last active November 19, 2015 15:46
Disable scroll to top on md-virtual-repeat by using this directive.

Angular Material v 1.0.0 currently does not support an option not to scroll to top when using md-virtual-repeat when items are removed. This directive is a quick fix that overrides default behaviour. Usage:

<md-virtual-repeat-container>
    <div md-virtual-repeat="item in items" prevent-scroll>
    </div>
</md-virtual-repeat-container>
@igneus
igneus / collect_countries.rb
Created May 30, 2016 14:28
Country names harvested from the "countries" Ruby gem (https://github.com/hexorx/countries)
require 'countries'
require 'json'
require 'active_support'
require 'sort_alphabetical'
lang = ARGV[0] || 'cs'
data = ISO3166::Country
.all
.collect {|c| {name: c.translations[lang], code: c.alpha2} }