Skip to content

Instantly share code, notes, and snippets.

@stevejay
stevejay / vite-react-library.sh
Last active September 3, 2022 07:24
Script for scaffolding an app or library that is build using React + TypeScript + Vite + Vitest + Storybook + Playwright. The package manager used is Yarn Berry (non-PnP mode). The script has only been tested on macOS with the zsh shell. It was used to scaffold https://github.com/stevejay/ons-explorer
#!zsh
PACKAGE_MANAGER='yarn'
INSTALL_TAILWIND=true
# Run either with no args as an interactive script or with args for a non-interactive script.
HAS_ARGS=$([ ${#} -eq 0 ])
# Parse any command line args:
@pseudosavant
pseudosavant / createImageBitmap.js
Last active March 20, 2022 12:30 — forked from MonsieurV/createImageBitmap.js
createImageBitmap polyfill with support for CanvasImageSource (img, video, canvas) sources, Blobs, and ImageData. https://createimagebitmap-polyfill.glitch.me/
/*
* Polyfill for createImageBitmap
* https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap
*
* Supports CanvasImageSource (img, video, canvas) sources, Blobs, and ImageData.
*
* From:
* - https://dev.to/nektro/createimagebitmap-polyfill-for-safari-and-edge-228
* - https://gist.github.com/MonsieurV/fb640c29084c171b4444184858a91bc7
* Updated by:
@MonsieurV
MonsieurV / createImageBitmap.js
Last active February 16, 2021 11:04
createImageBitmap polyfill with Blob and ImageData source support
/*
* Safari and Edge polyfill for createImageBitmap
* https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap
*
* Support source image types Blob and ImageData.
*
* From: https://dev.to/nektro/createimagebitmap-polyfill-for-safari-and-edge-228
* Updated by Yoan Tournade <yoan@ytotech.com>
*/
if (!('createImageBitmap' in window)) {
@paulirish
paulirish / what-forces-layout.md
Last active April 28, 2024 14:20
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