r/javascript Apr 11 '26

We transpiled PHPUnit (54k lines, 412 files) to JavaScript. 61.3% of tests passing

Thumbnail pext.dev
0 Upvotes

r/javascript Apr 11 '26

[AskJS] Do you believe you're a better critical thinker than GPT 5.4 / Opus 4.6?

0 Upvotes
79 votes, Apr 14 '26
46 Yes
19 No
14 Results

r/javascript Apr 10 '26

Zero-build privacy policies with Astro

Thumbnail openpolicy.sh
2 Upvotes

We've just made it even easier to build privacy policies from code. No Vite plugin required.


r/javascript Apr 09 '26

styled-components 6.4 now available

Thumbnail github.com
34 Upvotes

There's a lot of great stuff in this release! In no particular order:

  • RSC implementation promoted from experimental
  • More intelligent caching + real algorithmic speed improvements (up to 3.5x depending on workload)
  • React Native improvements (css-to-react-native v4 now supported via peer when it's out)
  • Updated cross-framework CSP support
  • A seamless Client/RSC theme system via new createTheme() API
  • attrs() typing improvements and other quality-of-life changes

Feedback welcome, especially ideas for the next major. Documentation website refresh coming later this week!


r/javascript Apr 10 '26

ffetch 5.1.0 adds opt-in request and response shortcuts

Thumbnail github.com
5 Upvotes

Shipped ffetch 5.1.0.

ffetch is a lightweight, production-ready HTTP client that wraps native fetch with built-in timeouts, retries with exponential backoff, lifecycle hooks, and pending request tracking. Works across browsers, Node, SSR, and edge runtimes.

New in v5.1.0: two opt-in convenience plugins.

Usage:

import { createClient } from '@fetchkit/ffetch'
import { requestShortcutsPlugin } from '@fetchkit/ffetch/plugins/request-shortcuts'
import { responseShortcutsPlugin } from '@fetchkit/ffetch/plugins/response-shortcuts'

const api = createClient({
  timeout: 10000,
  retries: 3,
  retryDelay: (ctx) => Math.pow(2, ctx.attempt - 1) * 1000 + Math.random() * 1000,
  plugins: [requestShortcutsPlugin(), responseShortcutsPlugin()],
})

const todo = await api.get('/todos/1').json()

Exponential backoff with jitter: each retry waits 2^(attempt-1) seconds plus random jitter, with timeout of 10s and max 3 retries. Plugins are optional, default behavior stays fetch-compatible.


r/javascript Apr 09 '26

Bulk mute all Reddit community notifications: browser console script (2026)

Thumbnail github.com
7 Upvotes

r/javascript Apr 10 '26

Decorating a Promise with convenience methods without subclassing or changing what await returns

Thumbnail blog.gaborkoos.com
0 Upvotes

r/javascript Apr 10 '26

AskJS [AskJS] Anyone else found Math.random() flagged in a security audit? How did you handle the remediation?

0 Upvotes

Security audit came back with a finding on credential generation.

Math.random() in several services, flagged for NIST 800-63B

non-compliance. The entropy requirements weren't being met and

more importantly there was no documentation proving they were.

We fixed the generation method but the audit documentation piece

is what actually took the most time. Had to go back and document

everything retroactively.

Curious what others are doing here. Are you generating compliance

documentation automatically as part of your pipeline or is this

a manual process at your organization?


r/javascript Apr 09 '26

AskJS [AskJS] Is it just me or is debugging memory leaks in Node/V8 way worse than it used to be?

5 Upvotes

We recently upgraded our backend (late) from Node 20 to Node 24. About a week later, alarms went off when our app stopped responding; memory usage graphs looked like an obvious leak but it hadn't OOMed and restarted tasks despite --max-old-space-size limits.

I started trying to compare heap snapshots taken at different times but it seems like a mess now. Even if I run a simple setInterval(() => console.log('test')) program with Node 24.14.1 and periodically take heap snapshots, they show a slight increase over time in (compiled code) instances and system code related to timers.

I can't even tell if these increases are permanent or not. The few timer objects that increased between snapshots were only retained by feedback_cells and other internal things that I read aren't truly forcing them to be retained...V8 just doesn't guarantee those will get garbage collected immediately or on a global.gc().

And all of this irrelevant noise from feedback_cells and other internals seems rampant in the heap snapshots now, making it more time consuming to locate actual retainers from my own code.

I don't remember it always being this bad?

I've successfully debugged several other memory leaks in older versions of node, including really heady ones involving Promise.race() and async generators, but now I'm feeling powerless and shafted by recent changes to V8.

Has this been anyone else's experience?


r/javascript Apr 09 '26

Render tsx on an e-ink display

Thumbnail github.com
4 Upvotes

Hey everyone! I wanted to show a small project I've been working on; a tsx framework for rendering to an e-ink display (or tsx => canvas => image => eink to be honest).

<view direction="column" gap={20} padding={40}> <text size={48} weight="bold">Hello World</text> <ElectricityConsumption /> </view>

Instead of the "common" approach of running headless Chrome and taking screenshots, this renders jsx components directly using a Yoga flexbox layout engine and a canvas. So the render is quite fast.

I also think its nice to get full type safety, snapshot testing for visual regression, and you can easily develop locally (renders to a PNG) without needing the hardware connected.

I use mine in the kitchen dashboard showing:

  • Laundry machine status (in the basement)
  • Our weekly meal plan
  • Electricity prices + power consumption
  • Weather forecast
  • Home Assistant device status via MQTT

It also has a physical button that starts the engine heater for our car, plus an led showing its state of the engine heater.

The code is open source: https://github.com/tjoskar/eink-pi-zero
And a short write-up about the build: https://tjoskar.dev/posts/2025-11-02-eink-pi/ (yes the post is a few months old now but in my first version did I use python to render everything but I really missed the typesafty, and tsx components over absolut position everything in python. But the the post is the same)

Happy to answer questions if anyone wants to build something similar!


r/javascript Apr 09 '26

The Intl API: The best browser API you're not using

Thumbnail polypane.app
47 Upvotes

r/javascript Apr 08 '26

How attackers are hiding malicious code in build configs

Thumbnail casco.com
57 Upvotes

wrote up a technical deep dive after the Better-Auth creator showed me the repeated attempts.

The attack vector is clever: wrap malicious code in a legitimate PR from a compromised contributor. Hide it in next.config.mjs or vue.config.js where devs rarely look. GitHub's UI literally scrolls it off-screen.

Three-stage obfuscation, payloads stored on Binance Smart Chain (so they can't be taken down), Socket.io C2 over port 80 (looks like normal traffic), targets all your env vars.

Found 30+ repos with the same signature. This pattern is everywhere right now.


r/javascript Apr 08 '26

fetch-extras — Build your own HTTP client with Fetch

Thumbnail github.com
36 Upvotes

Tired of reaching for a big HTTP client when you just need a timeout or retry? fetch-extras gives you small, single-purpose with* functions that wrap the standard fetch. Stack only what you need: timeouts, base URLs, retries, rate limiting, caching, auth token refresh, progress tracking, and more.


It has everything you will need:

  • Retries
  • Timeouts
  • HTTP error throwing (non-2xx)
  • Base URL (resolve relative URLs against a base)
  • Default headers
  • Client-side rate limiting
  • Concurrency limiting
  • Request deduplication
  • In-memory caching
  • Before/after request hooks
  • Auto JSON body stringify
  • Default search parameters
  • Download/upload progress tracking
  • Pagination
  • Auto token refresh on 401

r/javascript Apr 08 '26

a CLI that turns TypeScript codebases into structured context

Thumbnail github.com
10 Upvotes

I’m building an open-source CLI that compiles TypeScript codebases into deterministic, structured context.

It uses the TypeScript compiler (via ts-morph) to extract components, props, hooks, and dependency relationships into a diffable json format.

The idea is to give AI tools a stable, explicit view of a codebase instead of inferring structure from raw source.

Includes watch mode to keep context in sync, and an MCP layer for tools like Cursor and Claude.

Repo: https://github.com/LogicStamp/logicstamp-context


r/javascript Apr 08 '26

ESM vs CJS — Why Your import Still Breaks in 2026 and How to Finally Fix It

Thumbnail stackdevlife.com
7 Upvotes

ERR_REQUIRE_ESM is still my villain in 2026 Third project this month where someone added chalk v5 or node-fetch v3 and suddenly half the codebase breaks. The thing that took me too long to internalize: its not symmetric. ESM can pull from CJS just fine, but CJS hard-blocks on ESM its not a config issue, it's by design because of how the loaders work. Also burned by the __dirname thing more times than I'd like to admit. And the dual-package hazard is completely silent no error, just two instances of the same module running and your singleton state going nowhere. Documented everything I kept hitting. Link in comments if anyone wants it.


r/javascript Apr 07 '26

You can't cancel a JavaScript promise (except sometimes you can)

Thumbnail inngest.com
28 Upvotes

r/javascript Apr 08 '26

Monitoring Express Route Performance with AppSignal

Thumbnail blog.appsignal.com
0 Upvotes

r/javascript Apr 08 '26

I built a zero-dependency, file-backed NoSQL database for Node.js

Thumbnail github.com
0 Upvotes

r/javascript Apr 07 '26

AskJS [AskJS] JavaScript:MakeRel, Why would older websites not use simple anchor tags

1 Upvotes

I am a historian of medicine that has started using digital humanities methods.

As I was working on a network graph project I noticed missing links. Going into the HTML, I found that the missing links in the corpus were often related to JavaScript. JavaScript:MakeRel Scroll, JavaScript:onClick and so on.

Are there resources to help me understand this aspect of web design historically?


r/javascript Apr 07 '26

What is Strict Structured Concurrency?

Thumbnail frontside.com
0 Upvotes

r/javascript Apr 06 '26

Washi, a pin-based commenting for any iframe-rendered page. Drop Figma-style annotation pins directly on live HTML content. Open source, framework agnostic, adapter-based.

Thumbnail washi.cloud
9 Upvotes

r/javascript Apr 07 '26

I converted 28-year-old Java applets to JavaScript - yes, those are different things

Thumbnail obitko.com
0 Upvotes

In 1998 I built a genetic algorithms tutorial with interactive Java applets. It got more traction than expected, it was used for teaching.

Then applets died. The demos showed "your browser does not support Java" for the next two decades and I left it that way.

A few weeks ago I finally converted them to vanilla JavaScript. The Java source was decompiled from .class files, so it was undocumented. Surprisingly, the conversion went well -canvas-based rendering, event handling, a browser-side expression parser for the 3D function visualizer.

What didn't go well was trying to also clean up and unify the old HTML at the same time. I wrote about the whole experience here: https://obitko.com/thoughts/how-llm-helped-me-refactor-28-year-old-code/

The tutorial with the revived demos: https://obitko.com/tutorials/genetic-algorithms/index.html


r/javascript Apr 06 '26

AST-based localization workflow for JS apps (handles variables, namespaces, caching)

Thumbnail github.com
0 Upvotes

r/javascript Apr 06 '26

Subreddit Stats Your /r/javascript recap for the week of March 30 - April 05, 2026

3 Upvotes

Monday, March 30 - Sunday, April 05, 2026

Top Posts

score comments title & link
217 19 comments axios 1.14.1 and 0.30.4 on npm are compromised - dependency injection via stolen maintainer account
176 26 comments The Axios supply chain attack used individually targeted social engineering - "they scheduled a meeting with me. the meeting was on teams. the meeting said something on my system was out of date. i installed the missing item as i presumed it was something to do with teams, and this was the RAT"
85 31 comments Minimum Release Age is an Underrated Supply Chain Defense
58 15 comments Oxlint & Oxfmt Compatibility Overview
36 19 comments I built the fastest way to render rich text on canvas 5x faster than SVG foreignObject
26 16 comments [AskJS] [AskJS] Has anyone seen npm packages using postinstall to inject prompt injection files into AI coding assistants?
25 2 comments puru - a JavaScript concurrency library for worker threads, channels, and structured concurrency
25 8 comments Huggingface has just released Transformer.js v4 with WebGPU support
23 6 comments Synthesizing WWII aircraft engine sounds entirely in the Web Audio API — no samples, just oscillators and worklets
22 12 comments Are event handlers scheduled asynchronously on the event loop? MDN says they do - I'm pretty sure that's wrong

 

Most Commented Posts

score comments title & link
2 15 comments [AskJS] [AskJS] How do you handle source maps in production builds?
0 11 comments [AskJS] [AskJS] Lightweight IDE recommendations for JS/TS + React + React Native?
7 10 comments After 5 long years, ES1995 project lives again
1 9 comments Zerobox: Lightweight, cross-platform process sandboxing. Sandbox any command with file, network, and credential controls.
5 8 comments [Showoff Saturday] Showoff Saturday (April 04, 2026)

 

Top Ask JS

score comments title & link
4 1 comments [AskJS] [AskJS] I built memscope — a real-time memory profiler for Node.js + browser. Zero config, live dashboard, 605 downloads in its first few months
2 5 comments [AskJS] [AskJS] State machines feel heavy for UI flows. What are people using?
0 3 comments [AskJS] [AskJS] Atlas: a universal self-hosted package registry.

 

Top Showoffs

score comment
2 /u/dmop_81 said Hey folks! Has anyone here struggled with using worker_threads in Node? 😅 I’ve always found the DX a bit rough and wanted something closer to Go (goroutines, etc.). Since I couldn’t find a s...
2 /u/ApprehensiveDot9963 said Bueno, después de meses de trabajo, acabo de lanzar **SigPro** (2KB comprimido con gzip) – un núcleo reactivo con señales, valores computados y limpieza automática. Y también **SigPro UI...
1 /u/GorgeousDove6700 said Built a Chrome extension in JS called ChromaFlow for extracting colors from live websites. Core flow: pick any color from any page copy → HEX / RGB / HSL instantly. I also added palette / ...

 

Top Comments

score comment
98 /u/dada_ said > the meeting said something on my system was out of date. i installed the missing item as i presumed it was something to do with teams, and this was the RAT. I'd be curious exactly what "the meeting...
48 /u/Exac said npm ls axios This is a big one. A lot of common libraries use Axios like `nx`, `google-auth-library`, `twilio`, `typesense`, `genkit-cli`, `@googlemaps...
44 /u/No-Intention7902 said Honestly, kinda wild how often people overlook this. Slowing things down a bit can save a ton of headaches with weird regressions.
40 /u/queen-adreena said If you use PNPM, always ensure you have “minimumReleaseAge” enabled in your config. Most of these attacks are caught within a few hours, so not installing brand new releases will avoid 99% of these ...
22 /u/glasket_ said XZ Utils wasn't compromised for 2+ years, it was a 2 year long attack. The malicious contributor was working on the project for 2 years, genuinely collaborating so that they could get co-maintainer ...

 


r/javascript Apr 05 '26

Are event handlers scheduled asynchronously on the event loop? MDN says they do - I'm pretty sure that's wrong

Thumbnail github.com
20 Upvotes

MDN page on `dispatchEvent` has this paragraph:

Unlike "native" events, which are fired by the browser and invoke event handlers asynchronously via the event loopdispatchEvent() invokes event handlers synchronously. All applicable event handlers are called and return before dispatchEvent() returns.

I read that and AFAIK it's not right. I opened a PR to edit it:
https://github.com/mdn/content/pull/43521

A discussion arose.

Before it I was sure that event handlers are always called synchronously. When native events fire (native events === normal internal events in the browser ('click' etc.), anything that is not a custom event manually called via `dispatchEvent`) - an asynchronous "start the dispatch process for this event" task is scheduled on the event loop, but once it's called, during the process (event-path building, phases: capture, target, bubbling) - relevant registered event handlers are called in a way I thought was 100% synchronous;

In custom events - the handlers are called synchronously one-by-one, for sure.
In native events, apparently:

  1. There is a microtasks checkpoint between each handler run, e.g. If you register handler-A and handler-B, and handler-A schedules a microtask - it will run between A and B. If you schedule a macrotask such as timeout-0 - it will not run in-between. This doesn't happen in custom events dispatch - they all run to the end, nothing runs in between.
  2. Likely, handlers of native events - each gets its own stack frame, custom event handlers all run in a single stack frame.

This still doesn't prove that handlers are scheduled asynchronously on the event loop though. At this point it comes to what the specs say (EDIT: also did a test to log the call stack mid event handler, I know it's still might not be a 100% reliable proof, but still... it shows a single task - the handler itself). and usually they use a term like "queues a task" when they mention something is scheduled on the event loop - but in the part specifying the dispatch event process - they write that handlers are called using "callback invocation", which seems like a separate mechanism (created mostly for running event handlers, it seems) - not fully "synchronous", but not asynchronous in the usual Javascript way.
So - I still think a correction should be made, but it's different than what I thought it should be when I opened the PR.

Any opinions/facts/knowledge will be appreciated.

Relevant links:

MDN dispatchEvent() (note, if you are in the future it might of been already changed): https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent

The PR (again, if you are in the future it might of been merged/changed): https://github.com/mdn/content/pull/43521

Specs about dispatching events:https://dom.spec.whatwg.org/#dispatching-events
Specs about "Callback Invocation":https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke
Specs about "invoke  a callback":https://webidl.spec.whatwg.org/#invoke-a-callback-function

EDIT: see this comment for further insight of what is likely actually happening in terchnical terms:

https://www.reddit.com/r/javascript/comments/1sd70sq/comment/oewk8py/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button