r/codesnip • • Oct 15 '26

Newly Available No more getReader() loops

Post image
3 Upvotes

The platform just killed another JavaScript snippet. 🔥

Async iterable streams are Baseline, newly available since September 2026. Safari 27 closed the gap.

Before this, reading a fetch body chunk by chunk meant getReader() and a while (true) loop.

Now ⤵️ it's one for await. 🤟

Bonus: break out of the loop, and the stream is canceled and unlocked for you. No manual releaseLock(). 😎

Want to keep it open? res.body.values({ preventCancel: true }).

MDN: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#async_iteration


r/codesnip • • Apr 29 '26

👋 Welcome to r/codesnip — introduce yourself and dig in

0 Upvotes

Hi everyone — I'm u/wanoo21, one of the mods here.

r/codesnip is a community for sharing and discovering short, useful code: snippets, one-liners, small utilities, patterns, and "I wish I'd known this sooner" tips. All languages and skill levels are welcome—as long as it's constructive and readable.

What to post

  • Snippets or small functions you're proud of or find handy

  • Language tips, idioms, or clever one-liners (with context)

  • Mini-gists or short examples that solve a real problem

  • "How would you write this?" question with a minimal code sample

  • Tools, libraries, or patterns worth a shout-out (tie them to actual code when you can)

Community vibe

We're aiming for friendly, helpful, and inclusive. Prefer clear titles, credit sources when it's not your own work, and keep discussions on-topic.

How to get started

  1. Say hi in the comments and tell us what you're building or learning.

  2. Post something today—even a tiny snippet or a quick question counts.

  3. Invite anyone who likes trading short, practical code ideas.

  4. If you're interested in helping moderate, reach out via modmail.

Thanks for being part of the first wave—let's make this a great place for code in small, useful bites.


r/codesnip • • Apr 29 '26

Who still remembers this HTML tag? 👇

Post image
0 Upvotes

Although it has been deprecated for such a long time (really long time), it's still supported by all browsers!

Anyway, not advised to use in production!

Oh man, we are so old ... 😑


r/codesnip • • Oct 10 '26

Newly Available AbortSignal.timeout() turned fetch timeouts into one argument 🔥

6 Upvotes

JavaScript ... another snippet. 🔥

AbortSignal.timeout() has been Baseline since April 2024 (Chrome 124, Firefox 100, Safari 16) and goes widely available on 18 Oct.

Before this, a fetch timeout meant an AbortController, a setTimeout, and remembering to call clearTimeout.

Now it's one argument.

It rejects with a TimeoutError, not an AbortError, so you can tell "too slow" from "user canceled". 👍

Need both? AbortSignal.any([userCtrl.signal, AbortSignal.timeout(5000)]). That one went widely available on 19 Sep.

MDN: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static


r/codesnip • • Aug 16 '26

Thinking of starting a new series of what’s new in the web, starting on Monday.

0 Upvotes

r/codesnip • • Oct 12 '26

Newly Available `Intl.Segmenter` killed another JavaScript library 😁

5 Upvotes

JavaScript killed another JavaScript library. 😁

Intl.Segmenter has been in Baseline since April 2024 (Chrome 87, Firefox 125, Safari 14.1) and will be widely available on 16 Oct.

Before this, "👍🏽".length was 4, and counting what users actually see meant shipping grapheme-splitter.

Now ⤵️ the browser does it.

Bonus: the same API, granularity: "word", gives you word splitting that works for Japanese and Thai too, where split(" ") falls apart. 🤟

MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter


r/codesnip • • Oct 20 '26

Limited Availability The `controls` attribute is coming to `<img>` 😁

Post image
5 Upvotes

controls attribute is coming after the image 😁.

Audio had it. Video had it. Images just got it. That's how Vision Pro turns a panorama into an immersive view; straight from HTML, no DIY player.

Safari 27. Not everywhere yet. But the web just got a little more spatial. 🥽 👀

WebKit: https://webkit.org/blog/18325/webkit-features-for-safari-27-0/


r/codesnip • • Oct 22 '26

Newly Available Scroll anchoring is now on by default in every major browser (overflow-anchor, Safari 27)

Post image
5 Upvotes

CSS + browsers just killed another JavaScript hack. 🔥

You're reading. An image loads above you. The page jumps. You lose your place.

Safari 27 turned on scroll anchoring by default, so now every major browser keeps you put. No scroll-restore JS. 😎

overflow-anchor is Baseline, newly available since September 2026. Safari 27 closed the gap. 🤟

Before this, stopping scroll jumps meant saving scrollY and restoring it after each lazy-loaded image, ad, or comment.

Now it's on by default. You only write CSS to opt out: overflow-anchor: none;

MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/overflow-anchor

Source X post: https://x.com/ipwanciu/status/2104564285221253244


r/codesnip • • May 15 '26

Tabular numbers in CSS

7 Upvotes

By default, many fonts use proportional numbers: a 1 is narrow, an 8 is wider, and the whole number can shift when the value changes. 

tabular-nums makes each digit take the same horizontal space, so the number keeps its shape and the right edge stays steady.

Play with a small demo I created here.


r/codesnip • • Aug 17 '26

The web just got a little more intelligent.

Post image
30 Upvotes

Meet `contrast-color()`: You give it any color; it returns either `black` or `white`, whichever provides better contrast.

Shipped in Chrome 147, Safari 26, Firefox 146, and Edge 147 (April 2026).

Pure CSS that guarantees readable text.

PS. If you want occasional frontend tips in your inbox, you can join here: https://bits.iprodan.dev


r/codesnip • • Oct 19 '26

Newly Available Need a half-transparent brand color without rewriting the whole color? Meet `alpha()` 🤔

Post image
11 Upvotes

Need a half-transparent brand color without rewriting the whole color? 🤔

Meet alpha(), a CSS function that takes an origin color and returns that same color with a modified alpha (transparency) channel. 👇

alpha() is Baseline, newly available since September 2026 (Chrome 151+, Firefox 155, Safari 27).

Before this, a 40% hover tint meant rewriting the whole relative color, including every channel. Now you only touch the alpha. I'd ship this now.

MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/alpha


r/codesnip • • Aug 25 '26

Newly Available `sibling-index()`, and `sibling-count()` are Baseline, newly available since August 2026.

Post image
13 Upvotes

Before this, staggered animations or dynamic layouts meant writing a bunch of :nth-child() rules.

Now you can do it cleanly.

sibling-index() → position of the element.
sibling-count() → total number of siblings.


r/codesnip • • 26d ago

Limited Availability Safari 27.3 beta will darken your site unless you set color-scheme

Post image
13 Upvotes

Safari 27.3 beta comes with Adaptive Dark Mode!

If your website isn't optimized for dark mode, Safari will darken it anyway, but it leaves your site alone if you set color-scheme: light dark or use the color-scheme meta tag.

So, be prepared.

WebKit post: https://webkit.org/blog/18541/introducing-adaptive-dark-mode/


r/codesnip • • Sep 02 '26

Limited Availability `progress()` just landed in the last engine. Chrome 138, Safari 26, Firefox 155 (yesterday).

Post image
15 Upvotes

MDN still says Limited; that’s badge lag. It works now.

It returns a 0–1 number for how far a value sits between a start and an end


r/codesnip • • Aug 18 '26

Small interactive demo showcasing `contrast-color()`.

18 Upvotes

I created a small interactive demo showcasing `contrast-color()`.

Go check it out https://iprodan.dev/l/contrast-color/


r/codesnip • • Oct 13 '26

Newly Available CSS just made BEM optional: `@scope` is Baseline 🤟

Post image
20 Upvotes

CSS just made BEM optional. 🤟

@scope is Baseline, newly available since March 2026.

Before this, keeping component styles from leaking meant long selectors, extra classes, or CSS-in-JS. 👎

Now you can lock styles to a subtree ⤵️

Links inside .article get the article style. Links inside .comments stay untouched.

Short article on the basic usage of @scope: https://iprodan.dev/blog/css-scope/ MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@scope


r/codesnip • • Oct 08 '26

CSS killed another centering hack: `align-content: center` works on a plain block 🔥

21 Upvotes

CSS killed another centering hack. 🔥

align-content: center works on a plain block. No flex, no grid. Baseline since April 2024 (Chrome 123, Firefox 125, Safari 17.4), widely available on Oct 16.

Before this, centering a single item vertically meant turning the box into a flex column.

Now ⤵️ one line.

MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/align-content


r/codesnip • • Oct 23 '26

Limited Availability A small example of `grid-lanes` with `columns` as the fallback

5 Upvotes

This is a small example of grid-lanes and columns ⤵️. columns are used as a fallback when grid-lanes aren't supported.

We probably don't appreciate columns as much as we should! 🤔

Play with it here: https://iprodan.dev/l/grid-lanes/


r/codesnip • • Aug 18 '26

Container style queries are Baseline as of May 2026

Post image
3 Upvotes

You can now style an entire component based on a CSS variable set on any parent. No prop drilling, extra classes, or JavaScript, just pure CSS reacting to context.

Now live in Chrome, Safari, Firefox, and Edge in the latest releases.


r/codesnip • • Jul 30 '26

There's always a way to get the default value of an input, even if the user has changed it.

Post image
2 Upvotes

r/codesnip • • Oct 09 '26

Newly Available `writing-mode` turned range sliders vertical. No more `rotate(-90deg)` 🔥

18 Upvotes

Stop rotating your range sliders. 🤟

Vertical form controls are Baseline since April 2024 (Chrome 124, Firefox 120, Safari 17.4), widely available on 18 Oct.

Before this, a vertical volume slider meant rotate(-90deg), fake widths and margin math, or a JS slider library.

Now ⤵️ the real <input type=range>, turned.

MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Writing_modes/Vertical_controls


r/codesnip • • Sep 03 '26

Limited Availability `attr()` is escaping `content`. 😁

Post image
10 Upvotes

For years, it could only spit out a string for `::before` and `::after`. Now, Firefox 155 lets you use it on any property, with types and fallbacks. Chrome 133+ already had it.

Not Baseline yet; wait for Safari, but this is the `attr()` we were promised. 🤟


r/codesnip • • Aug 11 '26

As of June 2026, HTTP has a new method - a GET with a Body

Post image
3 Upvotes

That's a small reminder!

As of June 2026, HTTP has a new method - a GET with a `body`

Meet QUERY (RFC 10008).

It lets you send complex queries in the body (like POST) while staying safe, idempotent, and cacheable (like GET). Already works on servers (Node.js, Go, Laravel…).

Browsers are still adding full support, usable now with care, with widespread adoption coming later in 2026+.


r/codesnip • • May 19 '26

That's a simple reminder to use `structuredClone` instead of the `JSON.parse/stringify` solution.

Post image
3 Upvotes

Widely available since March 2022.


r/codesnip • • Aug 14 '26

CSS Grid Lanes (aka Masonry) is here (almost)

Post image
12 Upvotes

CSS just killed another JavaScript library.

CSS Grid Lanes (aka Masonry) is here! Safari (26.4+) got it first — everyone else is still catching up.

That’s all it takes. ▲

No more Masonry.js, fragile Flexbox hacks, or calculating positions in JavaScript — just pure CSS that natively creates the classic Pinterest/waterfall layout.

Chrome/Edge/Firefox - behind the flag.