Skip to content

Instantly share code, notes, and snippets.

View timothyleerussell's full-sized avatar

Timothy Lee Russell timothyleerussell

View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active April 25, 2024 21:49
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
@ryanlewis
ryanlewis / Pager.cshtml
Created August 27, 2013 16:41
A Razor/ASP.NET MVC pager that is adaptable for any project (Developed for Umbraco)
@model Epiphany.Web.Models.PagerViewModel
@{
var showPages = 5;
var maxPage = (int) Math.Ceiling((decimal) Model.Total/Model.PageSize);
}
@*[[ PAGER PAGE:@Model.Page PAGESIZE:@Model.PageSize TOTAL:@Model.Total MAXPAGE:@maxPage ]]*@
<div class="pagination">
@peteboere
peteboere / jquery.alterclass.js
Created December 24, 2011 12:49
jQuery alterClass plugin: Remove element classes with wildcard matching. Optionally add classes.
/**
* jQuery alterClass plugin
*
* Remove element classes with wildcard matching. Optionally add classes:
* $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
*
* Copyright (c) 2011 Pete Boere (the-echoplex.net)
* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
*
*/