Skip to content

Instantly share code, notes, and snippets.

View bergie's full-sized avatar

Henri Bergius bergie

View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active April 24, 2024 12:47
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
handleMutations: (mutations) =>
for m in mutations
for node in m.removedNodes
doSomethingToRemoved node
for node in m.addedNodes
doSomethingToAdded node
if m.type is "characterData" or m.type is "attributes" or m.type is "childList"
doSomethingWithType(m)
observer = new MutationObserver handleMutations
observer.observe(document.getElementById('graph'), {subtree: true, childList: true, attributes: false, characterData: false})
@kig
kig / changelist.js
Created August 13, 2013 11:07
ChangeList library to do OT on JSON and Strings.
var ChangeList = {};
if (typeof module !== 'undefined') {
module.exports = ChangeList;
}
// Creates a new change list struct.
//
ChangeList.create = function(type) {
var type = type || ChangeList.Object;

The Scope class regulates lexical scoping within CoffeeScript. As you generate code, you create a tree of scopes in the same shape as the nested function bodies. Each scope knows about the variables declared within it, and has a reference to its parent enclosing scope. In this way, we know which variables are new and need to be declared with var, and which are shared with the outside.

Import the helpers we plan to use.

{extend, last} = require './helpers'

@sunpig
sunpig / pg-eu-2012.md
Created September 18, 2012 09:01
Notes from the PhoneGap EU Day 2012

PhoneGap EU Day 2012

Friday 14 Sep 2012, Compagnietheater Amsterdam


09:30 Opening remarks by Andre Charland (Adobe) @andrecharland

In the year since 1.0 was released, there have been 10,000,000+ visits to phonegap.com, and 1,000,000+ downloads of the phonegap software. build.phonegap.com, the automated build service (so you don't have to compile all the different targets yourself) has 100,000 users, and is due for a formal release "soon."

Regarding naming confusion, "Cordova" is the Open Source project, owned by the Apache foundation, and "PhoneGap" is Adobe's distribution. (Just like "Linux" is the core Open Source project, and "Ubuntu" is a distribution of it.)