A tiny (265 byte) utility to create state machine components using two pure functions.
The API is a single function that accepts 2 pure functions as arguments:
A tiny (265 byte) utility to create state machine components using two pure functions.
The API is a single function that accepts 2 pure functions as arguments:
| var path = require('path').join(__dirname, '..', 'package.json'); | |
| var pkg = require(path); | |
| ['babel', 'greenkeeper', 'bundlesize', 'devDependencies', 'eslintConfig'].forEach(function(key) { delete pkg[key] }); | |
| pkg.scripts = { postinstall: pkg.scripts.postinstall, donate: pkg.scripts.donate }; | |
| require('fs').writeFileSync(path, JSON.stringify(pkg, null, 2)); |
Blink decodes off the main thread for image elements and for CSS styles (an image as an element's background style, for example). Moving the decode to the compositor thread (or the compositor worker thread pool?) does free-up the main thread to work on other tasks. We call this deferred decoding. With deferred decoding, the decode work remains on the critical path for presenting a frame to the display, so it can still cause animation jank.
The HTMLImageElement.decode() API should help with the jank problem. Also deferred decoding does not work with SVG
image resources. There are still cases where decoding images happens synchronously on the main thread: 2D canvas drawImage()
and createPattern(), and WebGL texture uploads.
| // https://hg.mozilla.org/mozilla-central/rev/2f9043292e63 | |
| // Used to detect minification for automatic pretty printing | |
| const SAMPLE_SIZE = 30; // no of lines | |
| const INDENT_COUNT_THRESHOLD = 20; // percentage | |
| function isMinified (str) { | |
| let isMinified; | |
| let lineEndIndex = 0; | |
| let lineStartIndex = 0; | |
| let lines = 0; |
A Preact PWA port of Eric Bidelman's Lighthouse Viewer app. Zero-config PWA build powered by preact-cli.
Try it out: lighthouse-viewer.surge.sh.
| { | |
| "rewrites": [ | |
| { | |
| "source": "**", | |
| "destination": "/index.html" | |
| } | |
| ], | |
| "headers": [ | |
| { | |
| "source": "**", |
| const typeOf = ob => ob.toString() | |
| const forEach = (fn, l) => typeOf(l) === '[object Object]' | |
| ? forEach(k => fn(l[k], k), Object.keys(l)) | |
| : Array.from(l).forEach(fn) | |
| export const patch = (elm, node) => { | |
| if(elm === node) return elm | |
| if(typeOf(elm) === '[object Text]') { | |
| elm.textContent = node.textContent |
| <script src="/path/to/embed.umd.js"></script> | |
| <div id="foo"></div> | |
| <script> | |
| var parent = document.getElementById('foo') | |
| embed.renderWidget( | |
| 'foo', // widget name | |
| { a: 'b' }, // props | |
| parent // render into this | |
| ); |