Skip to content

Instantly share code, notes, and snippets.

@ziir
ziir / *constant-locals-loader.md
Created March 23, 2020 14:07 — forked from developit/*constant-locals-loader.md
Inline Webpack CSS Modules classNames, reducing bundle size. https://npm.im/constant-locals-loader

constant-locals-loader for Webpack

This loader optimizes the output of mini-css-extract-plugin and/or css-loader, entirely removing the potentially large CSS classname mappings normally inlined into your bundle when using CSS Modules.

Run npm install constant-locals-loader, then make these changes in your Webpack config:

module.exports = {
 module: {
@ziir
ziir / repro-firefox-mobile-android-file-objecturl-history-pushstate.html
Created June 2, 2019 12:34
Firefox Mobile (Android) can't use an ObjectURL from a local File after using history.pushState
<html>
<body>
<input type="file" id="file" accept="audio/mpeg" />
</body>
<script>
const input = document.getElementById('file');
input.addEventListener('change', (evt) => {
const file = evt.target.files[0];
history.pushState({}, 'Uploaded', '/uploaded');
const audio = new Audio(URL.createObjectURL(file));
const sampleButton = document.createElement('button');
const sampleForm = document.createElement('form');
sampleForm.setAttribute('id', 'sample-form-for-polyfill');
sampleButton.setAttribute('form', 'sample-form-for-polyfill');
document.body.appendChild(sampleForm);
document.body.appendChild(sampleButton);
const isIE11 = !(window.ActiveXObject) && 'ActiveXObject' in window;
const supportsButtonFormAttr = (
@ziir
ziir / what-forces-layout.md
Created October 7, 2016 15:35 — 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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
export class Vector3 {
constructor (...args) {
if (args[0] instanceof Vector3) {
this.set(other);
} else if (Array.isArray(args[0]) && args[0].length === 3) {
this.x = args[0][0];
this.y = args[0][1];
this.z = args[0][2];
} else if (Object.Keys(args[0]) && Object.Keys(args[0]).length === 3) {
this.x = other.x;
@ziir
ziir / node_debian_init.sh
Last active September 1, 2015 09:07 — forked from peterhost/node_debian_init.sh
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28