"First do it, then do it right, then do it better."
Just start. The journey to success often begins with a single step, but that first step can be the hardest to take. It's easy to get caught up in the fear of failure or the desire for perfection, but I hope this quote I first…
A black hole simulation in 140 bytes of JavaScript: 🤯
for(i=0;i<2e3;x.fillRect(i?960+i*S(F=260*(t+9)/i+S(i*i)):0,i?500+.2*(2*i*C(F)+2e4/i):0,K=i++?S(i)*9:2e3,K))x.fillStyle=R(99*i,2*i,i,i?1:.4)
CSS "content-visibility:auto" is amazing: skip rendering & painting offscreen content until needed. I got a ~1s faster render on a long HTML document on desktop, ~3s on mobile.
Introducing "Learning Patterns": - a free 435+ page book on JavaScript + React design & performance patterns from
@lydiahallie
and I. On the web, ePub & PDF.
A full free Stanford course on Web Security: by
@feross
🍪 HTTP(S), Cookies, Sessions
🛡Same Origin Policy
👿 Cross-Site Scripting (XSS)
☠️ Cross-Site Script Inclusion
🔑 WebAuthn
and more.
Tip: target="_blank" on links to other sites can expose your site to performance and security issues. To fix, add rel="noopener" or rel="noreferrer" to these links: ✅
Things to look for in a code review: Code is...
- Well designed
- Readable by others
- Doing what the author intended
- No more complex than needed
- Not degrading system code health
- Commented with the why vs. what
- Appropriately tested
- Sufficiently documented
How Spotify makes text on images more readable: a CSS linear-gradient overlay. More common these days, but still an effective technique for better color contrast.
Excited to announce "Learning Patterns": a free new visual book on the latest JavaScript design, rendering, and performance patterns from
@lydiahallie
and I. Available in ePub/PDF and on web, coming this year.
The specification for native image lazy-loading has been merged into the HTML standard! 🎉
Huge thanks to
@domfarolino
@annevk
@zcorpan
and many others! About:
"Your UI doesn't need to map one-to-one with your data's fields and values". Great thinking on simplicity from
@steveschoger
(whose Refactoring UI book is A+)
Tips for efficiently Googling. Search by:
Exact match > "javascript modules"
Scope to site > site:<domain> js
After a date > javascript after:2021
Before > javascript before:2019
Exclude a phrase > javascript -es5
Number range > javascript 2015..2021
Wildcard > "fix the * error"
This is a phenomenal web demo. Enabled by window.getScreenDetails() which provides basic live info (size, position etc) from all screens on the device.
Want to create responsive images fast? Try . Give it an image and it:
🖥️ Determines optimal breakpoints
🖼️ Generates <img srcset> code
📦 Creates a .zip of responsive images!
via
@katiehempenius
Priority Hints: hint the `importance` of a resource to prioritize downloading it sooner/later:
<img importance=low>
<img importance=high>
<img importance=auto> (default)
Works on <img>, <link> and fetch()
📗 Spec:
🏃♀️ Origin Trial:
Tip: You can name capture groups for Regular Expressions in JavaScript. Define a named capture in angle brackets <> and they get returned under .groups.
We’ve improved <img> lazy-loading in Chrome! The new thresholds for when we load <img loading=lazy>:
* Offer *much* better data-savings
* Are closer to JavaScript lazy-loading libraries
* Are rolling out to Chrome 79+
My lessons from the decade:
* You never stop learning
* You can't know everything
* Failure is healthy & helps us grow
* Your biggest competition is yourself
* Communication is key in life & work
* Be kind & empathize with others
* Value friends & family
* Get enough sleep :)
ResizeObserver lets us observe changes to the layout size of elements: It's in the latest Safari!
Now in *all* modern browsers, we can efficiently design components responsive to their container vs. just the viewport.
Tip:
@ChromeDevTools
can now override the content of Fetch/XHR requests! Great for mocking APIs without waiting on backend changes!
This and lots more in Chrome 117:
Use React? Render large lists efficiently with react-window: ~small library for virtualizing lists & grids. Renders what users can see vs all your items at once ⚡️
📢 Announcing… quicklink! <1KB library to..
⚡ Automatically prefetch links in the viewport during idle time
⏳ Attempt to make next-page navigations load faster
📡 Data-considerate: doesn't prefetch on 2G or if Data Saver on
AVIF is an image format that compresses to a smaller size than WebP or JPEG It's in Chrome 85, behind a flag in Firefox & can be a progressive enhancement!