Skip to content

Instantly share code, notes, and snippets.

View vjeux's full-sized avatar

Christopher Chedeau vjeux

View GitHub Profile
@vjeux
vjeux / gist:9045784
Created February 17, 2014 06:39
All browser globals
Number
Math
unescape
Object
Array
escape
Float32Array
Date
location
Int8Array
@vjeux
vjeux / gist:9045802
Created February 17, 2014 06:40
All globals
Number
Math
unescape
Object
Array
escape
Float32Array
Date
location
Int8Array
@vjeux
vjeux / ReactPerformance
Created March 10, 2014 20:47
React Performance
# Basic
Initial rendering takes ~25ms
Delete first takes ~30ms
Delete last takes ~15ms
Add `background: red` to the second element and delete the first, you'll see that the second element is still red. What happened is that everything moved around. The reason is that React doesn’t do the matching properly.
http://jsfiddle.net/vjeux/tXfDU/
@vjeux
vjeux / gist:9474059
Created March 10, 2014 20:51
React Performance - JSFest
# Basic
Initial rendering takes ~25ms
Delete first takes ~30ms
Delete last takes ~15ms
Add `background: red` to the second element and delete the first, you'll
see that the second element is still red. What happened is that everything
moved around. The reason is that React doesn’t do the matching properly.
var PanelList = React.createClass({
// lots of stuff that front-end engineer is working on
render: function() {
// ...
return (
<div>
var Button = React.createClass({
// Lots of complicated stuff
render: function() {
return (
// the designer can tweak this rendering as well
<span style={[styles.normal, this.props.active && styles.active]} >
// ...
</span>
var SomeClass = function() {
// constructor
}
copyProperties(SomeClass, {
staticMethodA: function() {
}
})
var SomeClassClosure = function() {
this.method = function() {}
}
new SomeClassClosure
// {method: fnA()}
new SomeClassClosure
// {method: fnB()} // a new fn is allocated each time
var SomeClassPrototype = function() {}
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule deepFreezeAndThrowOnMutationInDev
*/
/**
* If your application is accepting different values for the same field over
* time and is doing a diff on them, you can either (1) create a copy or
* (2) ensure that those values are not mutated behind two passes.
var React = React.createClass({
componentDidMount() {
// this.props instead of attrs
var xGif = this.xGif = Object.create(this.props, {
fire: {
value: function (event) {
console.log(event);
}
}