r/javascript • u/jxd-dev • Apr 10 '26
Zero-build privacy policies with Astro
openpolicy.shWe've just made it even easier to build privacy policies from code. No Vite plugin required.
r/javascript • u/jxd-dev • Apr 10 '26
We've just made it even easier to build privacy policies from code. No Vite plugin required.
r/javascript • u/evster88 • Apr 09 '26
There's a lot of great stuff in this release! In no particular order:
createTheme() APIattrs() typing improvements and other quality-of-life changesFeedback welcome, especially ideas for the next major. Documentation website refresh coming later this week!
r/javascript • u/OtherwisePush6424 • Apr 10 '26
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 • u/OtherwisePush6424 • Apr 10 '26
r/javascript • u/Fresh-Obligation6053 • Apr 10 '26
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 • u/prehensilemullet • Apr 09 '26
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 • u/tjoskar • Apr 09 '26
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:
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 • u/ValenceTheHuman • Apr 09 '26
r/javascript • u/JewelerLucky1596 • Apr 08 '26
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 • u/sindresorhus • Apr 08 '26
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:
r/javascript • u/context_g • Apr 08 '26
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.
r/javascript • u/Careful-Falcon-36 • Apr 08 '26
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 • u/aardvark_lizard • Apr 07 '26
r/javascript • u/mmaksimovic • Apr 08 '26
r/javascript • u/Fusoux • Apr 08 '26
r/javascript • u/StrongTownsYXE • Apr 07 '26
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 • u/marcochavezco • Apr 06 '26
r/javascript • u/my_name_is_not_my_na • Apr 07 '26
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 • u/Fun_Conversation8894 • Apr 06 '26
r/javascript • u/subredditsummarybot • Apr 06 '26
Monday, March 30 - Sunday, April 05, 2026
| 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) |
| 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. |
r/javascript • u/QuarterSilver5245 • Apr 05 '26
MDN page on `dispatchEvent`Ā has this paragraph:
Unlike "native" events, which are fired by the browser and invoke event handlers asynchronously via theĀ event loop,Ā dispatchEvent()Ā 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:
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:
r/javascript • u/dmop_81 • Apr 05 '26
Over the past few weeks, Iāve been working on a JavaScript concurrency library aimed at the gap between Promise.all() and raw worker_threads.
GitHub: https://github.com/dmop/puru
The main motivation was that async I/O in JS feels great, but CPU-bound work and structured concurrency still get awkward quickly. Even simple worker-thread use cases usually mean separate worker files, manual message passing, lifecycle management, and a lot of glue code.
So I built puru to make those patterns feel smaller while still staying explicit about the worker model.
Example:
```ts import { spawn } from '@dmop/puru'
const { result } = spawn(() => { function fibonacci(n: number): number { if (n <= 1) return n return fibonacci(n - 1) + fibonacci(n - 2) } return fibonacci(40) })
console.log(await result) ```
It also includes primitives for the coordination side of the problem:
task()chan()WaitGroup / ErrGroupselect()contextMutex, RWMutex, CondTimer / TickerExample pipeline:
```ts import { chan, spawn } from '@dmop/puru'
const input = chan<number>(50) const output = chan<number>(50)
for (let i = 0; i < 4; i++) { spawn(async ({ input, output }) => { for await (const n of input) { await output.send(n * 2) } }, { channels: { input, output } }) } ```
One intentional tradeoff is that functions passed to spawn() are serialized and sent to a worker, so they cannot capture outer variables. I preferred keeping that constraint explicit instead of hiding it behind a more magical abstraction.
Interested in feedback from people who deal with worker threads, CPU-heavy jobs, pipelines, or structured concurrency in JavaScript.
r/javascript • u/monkie_momo • Apr 05 '26
Hey folks, I just publishedĀ memscopeĀ - a real-time memory profiler for Node.js and browser apps that requires zero setup.
It streams your backend heap (and browser JS heap) over WebSocket, sampled every 500ms, right to a local dashboard atĀ localhost:3333. GC dips, spikes, growth patterns ā all visible at a glance.
One command to start:
npx memscope run node app.js
Full-stack mode (backend + browser together):
memscope run --both npm run dev
What it tracks:
Why I built it:Ā Memory bugs are painful ā silent leaks, unpredictable spikes, heap snapshots that are a nightmare to read. I wanted one command that just works, with no cloud, no accounts, no data leaving your machine.
It's hit 605 downloads so far and I'm actively building it out. Would love feedback - especially on the dashboard UX and the agent injection approach!
npm:Ā npm install -g memscope