Introducing Preact Signals: a reactive state primitive that is fast by default.
โ feels like using plain values
๐ฅณ automatic updates when values change
โฑ updates DOM directly (fast!)
๐ฅน no dependencies arrays
Please don't import SVGs as JSX. It's the most expensive form of sprite sheet: costs a minimum of 3x more than other techniques, and hurts both runtime (rendering) performance and memory usage.
This bundle from a popular site is almost 50% SVG icons (250kb), and most are unused.
๐โโ๏ธ Cost of updating text in the DOM
โฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธ .innerHTML
โฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธ .textContent
โฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธ .innerText
โฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธ .firstChild.data
- Use innerText if you can't assume structure
- Use Text
#data
to update existing text
๐ฉโ๐ Introducing ๐ช๐ ๐ฅ:
The tiny all-in-one development tool for modern web apps.
Everything you need to build a fast Preact site, from dev to prod.
๐ฆ TSX, HMR, CSS Modules, etc
๐ฆฆ use npm modules without installing
๐ฆ one 2mb file, no dependencies
โ
๐ธ Cost of updating text in the DOM: 2019 Edition
โฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธโฌ๏ธ .innerHTML
โฌ๏ธโฌ๏ธโโโโ .textContent
โฌ๏ธโฌ๏ธโโโโ .innerText
โฌ๏ธโโโโโ .firstChild.data
- Use .textContent if you can't assume structure
- Use Text
#data
to update existing text
๐ฃ Introducing.. prerender-loader!
๐ฐ Painless universal pre-rendering for Webpack.
โน๏ธโโ๏ธ Improve first paint, often without a code change!
โจ
Last week, Preact hit 1 million weekly downloads.
The little library I built in 2015 as a learning exercise is now found on ~4% of websites, including some of the most visited websites globally.
I'm lucky to work with this awesome team, and excited for what's shipping in 2022.
๐ฃ Introducing Workerize:
Offload modules into Web Workers with a simple prefix! ๐
Statically compiles exports to reflected async functions ๐
โจ
Tomorrow is my last day at Google. ๐
It's been an amazing experience, marked by a wonderful group of friends who I'll miss (virtually) hanging out with.
The next chapter in this adventure will take place at Shopify, starting in May.
๐ฆ Size Plugin for Webpack!
๐ต๏ธโโ๏ธ Keep an eye on those bundle sizes...
๐๏ธโโ๏ธ Shows compressed sizes
#๏ธโฃ Compares even if file hashes change
> npm i -D size-plugin
New state model for VDOM dramatically simplifies your code, and is also kinda performance magic.
Left: standard component rendering
Right: same code with optimization enabled
(no compile, just a library and stock
@preactjs
)
It's time to enable modern JavaScript npm libraries.
This post by
@GaryLChew
explains the current state and ways forward.
I think the combined solution is compelling.
I finally got around to testing out VSCode Online today.
Here it is running as a Desktop PWA.
To me, this is basically indistinguishable from local VSCode, except the Mac's fans aren't spinning.
Redaxios is an ~800b Axios stand-in built on Fetch.
0.3 just added support for the baseURL, responseType, params, paramsSerializer and withCredentials options, plus fetch mocking and FormData support.
Houssein just announced something I've been working on for a little while:
@babel
/preset-modules!
A Babel preset that enables native async/await, Tagged Templates, arrow functions, destructured and rest parameters, and more - in 88% of browsers.
Introducing web-worker:
Native universal Web Workers
1๏ธโฃ one import for web + Node
๐งฐ the same Web Worker API everywhere
๐ uses worker_threads and native ESM
๐ธ zero-cost in the browser
๐ฆ works in npm modules
โ ๏ธ You probably don't want .innerText
Why? It triggers layout! ๐ฆ
This happens because the string contains newlines corresponding to blocks, and hidden content is omitted.
๐โโ๏ธ Solution: use .textContent instead.
I have been working on an experimental ground-up rewrite of Preact's renderer. It now renders TodoMVC faster than hand-written vanilla JS.
It's somewhere between 1.5x and 3x faster than Preact 10 (depending on VM optimization state).
๐ฃ I'm excited to announce a new lib: unistore.
A 700-byte centralized state implementation for Preact.
Featuring:
๐ built-in data selectors
๐ pure component-bound actions
โฑ simple, painless async
All JS bundlers + runtimes now support Package Exports.
As you add the "exports" field to your npm module, please remember: modules referenced via "exports" can include modern syntax.
Adding exports is a semver-major change. It's a great opportunity to publish modern code too.
๐Constructable Stylesheets are here!๐ทโโ๏ธ
TL;DR: Seamless reusable styles for components and elements. Shadow DOM.
๐ load stylesheets asynchronously
๐ apply them to shadow roots or globally
๐ฆ no FOUC for loaded sheets
I keep writing this useMount() hook.
It's easier to scan for in code than useEffect.
Basically my brain can't remember this:
useEffect(fn) // run after each render
useEffect(fn, []) // runs after mount
๐ฃ Introducing worker-plugin for Webpack!
๐ณ Automatically compile and bundle Workers.
๐งโโ๏ธ No special syntax, no config.
๐ worker = new Worker('./foo', { type: 'module' })
I regret using Tailwind for this mastodon client. I had kinda assumed it'd make things like dark mode easier, but so far it has just made initially throwing a view together slightly quicker at the expense of making everything else much more arduous/brittle.
What if you could have a full dev setup + server in a single 150kb JS module?
What if that setup included ~instant Hot Module Replacement, JSX support, sourcemaps & friendly errors?
What if you never had to run `npm install` and your node_modules directory was 0 bytes?
๐ฆ SSR for web components! ๐ฆ
Declarative Shadow DOM is a proposed web platform feature that brings Shadow DOM to HTML.
Try it in Chrome (experimental flag) or via a polyfill:
๐
My reverse compiler project now recognizes and removes unnecessary polyfills. (and ponyfills!)
(not shown: cascades and can even remove the wrapper function)
HTM 2.1 is out:
๐งโโ๏ธ
@jviide
rewrote it, twice.
it's faster. it's smaller. it doesn't violate CSP.
๐ฃthere's a new htm/mini version: <400 bytes
๐you can now compile JSX to HTM.
Get those sweet Tagged Template gainzz๐ฆต
๐Easy `htm/react` integration
Just so it doesn't get buried: we built Signals for Preact, but it works in React too - even the fancy granular text updates! Just import the
@preact
/signals-react package.
How to drop IE11 support while keeping your site accessible (including from IE):
1. Build your site to work properly without JavaScript.
2. Load JS via <script type=module>, which IE ignores
Think about it: bogging IE11 down with 2mb of polyfilled JS reduces accessibility.