Skip to content

Instantly share code, notes, and snippets.

View codemilli's full-sized avatar
😇
Hooked on React Hooks

codemilli codemilli

😇
Hooked on React Hooks
  • Zemilli Design Studio
  • Seoul, South Korea
  • X @codemilli
View GitHub Profile
@codemilli
codemilli / what-forces-layout.md
Created September 2, 2022 03:52 — forked from paulirish/what-forces-layout.md
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
@codemilli
codemilli / hacky-scrollbar-resize-listener.js
Created February 23, 2017 08:36 — forked from OrganicPanda/hacky-scrollbar-resize-listener.js
A sham that will throw a window resize event even when scrollbars are added/removed (this is not something the standard window resize event does). Tested in IE9+, Chrome & Firefox latest.
// Demo: http://jsfiddle.net/pFaSx/
// Create an invisible iframe
var iframe = document.createElement('iframe');
iframe.id = "hacky-scrollbar-resize-listener";
iframe.style.cssText = 'height: 0; background-color: transparent; margin: 0; padding: 0; overflow: hidden; border-width: 0; position: absolute; width: 100%;';
// Register our event when the iframe loads
iframe.onload = function() {
// The trick here is that because this iframe has 100% width
@codemilli
codemilli / introrx.md
Created February 28, 2016 10:42 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@codemilli
codemilli / gist:9db0c48f7d7fa0d18baa
Created January 23, 2016 01:29
how I write modules
My thoughts on writing tiny reusable modules that each do just one
thing. These notes were adapted from an email I recently sent.
***
If some component is reusable enough to be a module then the
maintenance gains are really worth the overhead of making a new
project with separate tests and docs. Splitting out a reusable
component might take 5 or 10 minutes to set up all the package
overhead but it's much easier to test and document a piece that is