Skip to content

Instantly share code, notes, and snippets.

architectures and whatnot

  1. plain ol' React
let state = initial
render(view(state), element)
  • view is pure!
@paulirish
paulirish / what-forces-layout.md
Last active April 26, 2024 05: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
@gauntface
gauntface / toggle-remote-styles.js
Last active March 12, 2020 12:56
A book marklet to toggle styles.
javascript:(function(){var styles = document.querySelectorAll('link[rel=\'stylesheet\']'); for (var s = 0; s < styles.length; s++) {styles[s].mediax = styles[s].media;if (styles[s].media === 'only x') { styles[s].media = styles[s].mediax; } else if (styles[s].media !== 'print') {styles[s].media = 'only x';}}})();
@k33g
k33g / index.html
Last active April 18, 2019 05:49
Vue.js + ES6
<div id="demo">
<h1>{{bob.fields.firstName}} {{bob.fields.lastName}}</h1>
</div>
<ul id="humans-list">
<li v-repeat="humans">
{{fields.firstName}} {{fields.lastName}}
</li>
</ul>
@jeffmo
jeffmo / gist:054df782c05639da2adb
Last active January 11, 2024 06:05
ES Class Property Declarations