Skip to content

Instantly share code, notes, and snippets.

View metteo's full-sized avatar

Grzegorz Nowak metteo

  • novaware
  • Krakow, Poland
View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active April 28, 2025 06:24
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
Benchmark (arg) Mode Samples Score Error Units
o.s.MyBenchmark.baseline 1 avgt 50 5.346 ñ 0.033 ns/op
o.s.MyBenchmark.baseline 100 avgt 50 5.402 ñ 0.053 ns/op
o.s.MyBenchmark.baseline 10 avgt 50 5.409 ñ 0.067 ns/op
o.s.MyBenchmark.baseline 1000 avgt 50 5.409 ñ 0.057 ns/op
o.s.MyBenchmark.baseline 5 avgt 50 5.373 ñ 0.057 ns/op
o.s.MyBenchmark.mapTest 1 avgt 50 6.989 ñ 0.044 ns/op
o.s.MyBenchmark.mapTest 100 avgt 50 7.259 ñ 0.111 ns/op
o.s.MyBenchmark.mapTest 10 avgt 50 7.125 ñ 0.159 ns/op
o.s.MyBenchmark.mapTest 1000 avgt 50 7.674 ñ 0.048 ns/op
@tleen
tleen / gist:f7b3e40c8b3ad976df05
Created September 22, 2014 22:33
Create empty gh-pages branch for GitHub Pages
git checkout --orphan gh-pages
@svenefftinge
svenefftinge / I18Processor.xtend
Created August 9, 2013 06:04
An annotation processor for localization using Java Resource Bundle
@Active(ExternalizedProcessor)
annotation Externalized {}
class ExternalizedProcessor extends AbstractClassProcessor implements CodeGenerationParticipant<ClassDeclaration> {
override doTransform(MutableClassDeclaration annotatedClass, extension TransformationContext context) {
for (field : annotatedClass.declaredFields) {
val initializer = field.initializerAsString
val msgFormat = try {
new MessageFormat(initializer)
@swankjesse
swankjesse / Rip.java
Created February 8, 2013 23:27
Stream editor for Java nerds. Use Java regular expressions to break up lines, and Java format strings to put them back together again.
/*bin/mkdir /tmp/rip 2> /dev/null
javac -d /tmp/rip $0
java -cp /tmp/rip Rip "$@"
exit
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.Matcher;
@tbroyer
tbroyer / Html5Historian.java
Created February 22, 2012 10:07
GWT PlaceHistoryHandler.Historian using HTML5 pushState and onpopstate
/*
* Copyright 2012 Thomas Broyer <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
#!/bin/bash
# SPDX-License-Identifier: MIT
## Copyright (C) 2009 Przemyslaw Pawelczyk <[email protected]>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
#
# Lockable script boilerplate