Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
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
@LukyVj
LukyVj / SassMeister-input.scss
Last active October 23, 2018 07:39
Generate SVG icon font with color change possibility (without changing the fill), with a IE fallback.
// ----
// libsass (v3.2.5)
// ----
$version: "0.1.1";
/* This CSS is generated by My SASSVG-iconic Mixin #{$version}. */
$icon-list: 'twitter', 'facebook', 'instagram';
$icon-list:(
@adactio
adactio / Twig-critical-CSS-test.twig
Last active January 30, 2024 07:13
Twig template for inlining critical CSS on first visits.
{% set cssupdate = '20150309' %}
{% if _cookie.csscached == cssupdate %}
<link rel="stylesheet" href="/css/global-min.{{ cssupdate }}.css">
{% else %}
<style>
{% include 'global/critical.css' %}
</style>
<script>
(function (win, doc) {
'use strict';
@LeaVerou
LeaVerou / dabblet.css
Created March 17, 2014 04:32
Gradient cheatsheet
/* Gradient cheatsheet */
background: linear-gradient(45deg, white, black);
background: linear-gradient(to right, white 50%, red, black);
background: linear-gradient(to bottom right, white 50px, black);
background: repeating-linear-gradient(to bottom left, white, black 30px);
background: radial-gradient(at top right, white, black);
background: radial-gradient(circle at top right, lime 50%, black 0);
background: radial-gradient(farthest-corner at center, red 80%, black);
background: radial-gradient(farthest-side at center, yellow 80%, black);
@yitwail
yitwail / custom.js
Created November 17, 2013 22:42
changes to js/custom.js for iPad dropdown menu support
// apply fitvids functionality to .entry-content div
// https://github.com/davatron5000/FitVids.js
jQuery(document).ready(function($) {
$(".entry-content").fitVids();
});
// modified version of flexnav, does not have drop down functionality
// https://github.com/indyplanets/flexnav
// http://webdeveloper2.com/2011/06/trigger-javascript-on-css3-media-query-change/
jQuery(document).ready(function($) {
<?php
add_action ('admin_init', 'childtheme_opt_init');
/**
* Add childtheme settings to the thematic theme
*
* This will add childtheme options to the thematic theme settings
* in the database, and add to the existing theme options page in Thematic
**/
function childtheme_opt_init() {