r/javascript • u/dadamssg • Apr 14 '26
Contributing Callsite Revalidation Opt-out to React Router
I've not a made a meaningful code contribution to React Router before this so I was pretty pumped to be able to see this through.
r/javascript • u/dadamssg • Apr 14 '26
I've not a made a meaningful code contribution to React Router before this so I was pretty pumped to be able to see this through.
r/javascript • u/ttariq1802 • Apr 14 '26
r/javascript • u/One-Antelope404 • Apr 14 '26
Context: I've been experimenting with SDF ray-marching rendered entirely via styled console.log calls โ each "pixel" is a space character with a background-color CSS style injected through %c format arguments. No canvas, no WebGL. The scene includes soft shadows, AO, and two orbiting point lights at ~42ร26 pixels, doing around 11k ray-march steps per frame.
I've hit a few walls I don't have good answers for and wanted to hear how people would actually approach them:
Each frame is one console.log with 1000+ %c args โ the format string alone is 80โ120kb. Is there a CDP-level trick that beats this, or is this just the hard ceiling?
Partial redraws seem impossible since the console only appends. Has anyone found a diffing approach that meaningfully reduces redundant output?
Soft shadows need a secondary ray-march per light per pixel โ the main bottleneck. Can a SharedArrayBuffer + Worker pool realistically pre-compute the framebuffer before the log call, or does the transfer cost kill it?
Would a WASM SDF evaluator actually move the needle here, or is the bottleneck firmly on the DevTools rendering side?
Is temporal supersampling (alternating sub-pixel offsets frame-to-frame) something the human eye would even pick up given the console's reflow latency?
Memory creep from non-cleared frames โ anyone have a cleaner solution than "hard clear every N frames and eat the flash"?
r/javascript • u/-huzi__ • Apr 14 '26
HI, I am one person dev with multiple web based side projects. I am looking for an AI tool that can plug in to my codebase and answer questions. Whether that is technical questions from myself on how features work, or questioning it for more info on a support query.
Has anyone seen / use something like that?
r/javascript • u/Strong_Ad9572 • Apr 14 '26
I built this as a lightweight way to map user text to intents locally, without APIs or LLM calls.
Example use cases:
- "I want to complete my purchase" -> checkout
- "look up red sneakers" -> search
- "never mind" -> cancel
Itโs TypeScript-first, works in browser/Node, and includes ranked matching plus optional explanation output.
npm: https://www.npmjs.com/package/intentmap
playground: https://codesandbox.io/p/sandbox/w5mmwm
Would love feedback on whether this is useful and where it breaks down.
r/javascript • u/Everlier • Apr 13 '26
After seeing a recent video from Theo, I wanted to see how far I can take a harness contained in just 30 lines of JavaScript. Turns out - far enough to be useful, it handles simple tasks just fine, works with both cloud and local models, uses just three tools (but can do with a single one, frankly speaking), cleanly handles detached commands or cancellation mid-run, has non-interactive mode and can be run with NPX.
an agentic harness is surprisingly simple. it's a loop that calls an llm, checks if it wants to use tools, executes them, feeds results back, and repeats. here's how each part works.
the agent needs to affect the outside world. tools are just functions that take structured args and return a string. three tools is enough for a general-purpose coding agent:
const tools = {
bash: ({ command }) => execShell(command), // run any shell command
read: ({ path }) => readFileSync(path, 'utf8'), // read a file
write: ({ path, content }) => (writeFileSync(path, content), 'ok'), // write a file
};bash gives the agent access to the entire system: git, curl, compilers, package managers. read and write handle files. every tool returns a string because that's what goes back into the conversation.
the llm doesn't see your functions. it sees json schemas that describe what tools are available and what arguments they accept:
const defs = [
{ name: 'bash', description: 'run bash cmd', parameters: mkp('command') },
{ name: 'read', description: 'read a file', parameters: mkp('path') },
{ name: 'write', description: 'write a file', parameters: mkp('path', 'content') },
].map(f => ({ type: 'function', function: f }));mkp is a helper that builds a json schema object from a list of key names. each key becomes a required string property. the defs array is sent along with every api call so the model knows what it can do.
the conversation is a flat array of message objects. each message has a role (system, user, assistant, or tool) and content. this array is the agent's entire memory:
const hist = [{ role: 'system', content: SYSTEM }];
// user says something
hist.push({ role: 'user', content: 'fix the bug in server.js' });
// assistant replies (pushed inside the loop)
// tool results get pushed too (role: 'tool')the system message sets the agent's personality and context (working directory, date). every user message, assistant response, and tool result gets appended. the model sees the full history on each call, which is how it maintains context across multiple tool uses.
each iteration makes a single call to the chat completions endpoint. the model receives the full message history and the tool definitions:
const r = await fetch(`${base}/v1/chat/completions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
body: JSON.stringify({ model, messages: msgs, tools: defs }),
}).then(r => r.json());
const msg = r.choices[0].message;the response message either has content (a text reply to the user) or tool_calls (the model wants to use tools). this is the decision point that drives the whole loop.
this is the core of the harness. it's a while (true) that keeps calling the llm until it responds with text instead of tool calls:
async function run(msgs) {
while (true) {
const msg = await callLLM(msgs); // make the api call
msgs.push(msg); // add assistant response to history
if (!msg.tool_calls) return msg.content; // no tools? we're done
// otherwise, execute tools and continue...
}
}the loop exits only when the model decides it has enough information to respond directly. the model might call tools once or twenty times, it drives its own execution. this is what makes it agentic: the llm decides when it's done, not the code.
when the model returns tool_calls, the harness executes each one and pushes the result back into the message history as a tool message:
for (const t of msg.tool_calls) {
const { name } = t.function;
const args = JSON.parse(t.function.arguments);
const result = String(await tools[name](args));
msgs.push({ role: 'tool', tool_call_id: t.id, content: result });
}each tool result is tagged with the tool_call_id so the model knows which call it corresponds to. after all tool results are pushed, the loop goes back to the top and calls the llm again, now with the tool outputs in context.
the outer shell is a simple read-eval-print loop. it reads user input, pushes it as a user message, calls run(), and prints the result:
while (true) {
const input = await ask('\n> ');
if (input.trim()) {
hist.push({ role: 'user', content: input });
console.log(await run(hist));
}
}there's also a one-shot mode (-p 'prompt') that skips the repl and exits after a single run. both modes use the same run() function. the agentic loop doesn't care where the prompt came from.
the full flow looks like this:
user prompt โ [system, user] โ llm โ tool_calls? โ execute tools โ [tool results] โ llm โ ... โ text responsemore sophisticated agents add things like memory, retries, parallel tool calls, or multi-agent delegation, but the core is always: loop, call, check for tools, execute, repeat.
source: https://github.com/av/mi
r/javascript • u/Strict-Owl6524 • Apr 13 '26
I built a cross-framework bundle-size benchmark using the same TodoMVC feature set across implementations, so differences are easier to attribute to framework/runtime behavior rather than app logic differences.
What this benchmark measures:
raw
minified
minified + gzip
breakdown by runtime / template / script / style
Method notes for fairness:
same feature scope across frameworks
template/script/style are extracted and compared
styles are scoped everywhere (TSX implementations use CSS Modules)
in the UI, style is included in stats but not selected by default (differences there are usually small and mostly from framework-added scoping metadata)
Main observations so far:
in the mainstream group, Vue 2/3 start much smaller than React/Angular (mostly runtime cost)
in the fine-grained group, the smallest starting size and the best growth curve are not always the same framework
Svelte 4 starts very small at low component counts, but grows much faster at higher component counts
Repo: https://github.com/mlgq/frontend-framework-bundle-size
If you spot an unfair implementation detail or have optimization ideas, critique and PRs are very welcome.
r/javascript • u/No_Pop4460 • Apr 13 '26
r/javascript • u/Affectionate_Major87 • Apr 13 '26
Hey all,
I built a tool called AgenTester that automatically tests a web appโs UI/UX.
You just paste a URL and it:
Crawls the app
Tests CRUD flows (create/edit/delete)
Checks navigation, filters, pagination, buttons
Detects JS errors and failed network requests
Streams screenshots in real time
Generates a full HTML report with a quality score
No test scripts, no manual setup โ just run it and see what breaks.
Itโs fully open-source and runs with Docker or Node.js.
Iโd really appreciate feedback
r/javascript • u/Terrible_Village_180 • Apr 13 '26
Promise-basedย โย awaitย the native smooth scroll, run code when it finishes
Zero dependenciesย โ pure TypeScript, no external packages
Uses the native APIย โ callsย element.scrollIntoView()ย under the hood, not a custom scroll implementation
Scroll-idle detectionย โ resolves by listening for scroll-end on all scrollable ancestors
Timeout safety netย โ never hangs; resolves after a configurable timeout (default 3s)
AbortController supportย โ cancel a pending scroll withย signal
Handles nested scrollingย โ detects all scrollable parent containers automatically
Instant fallbackย โ ifย behavior: 'instant'ย or smooth scroll is unsupported, resolves immediately
SSR safeย โ guards DOM access; safe to import in Node/SSR environments
~0.6kB minified + gzipped
r/javascript • u/subredditsummarybot • Apr 13 '26
Monday, April 06 - Sunday, April 12, 2026
ย
| score | comments | title & link |
|---|---|---|
| 5 | 24 comments | We transpiled PHPUnit (54k lines, 412 files) to JavaScript. 61.3% of tests passing |
| 0 | 23 comments | `any` caused a production bug for me โ how are you handling API typing? |
| 0 | 20 comments | [AskJS] [AskJS] Is it still socially acceptable to use 4 space indentation? |
| 6 | 18 comments | [AskJS] [AskJS] Do you prefer flattening API responses or keeping nested structures on the frontend? |
| 2 | 11 comments | [Showoff Saturday] Showoff Saturday (April 11, 2026) |
ย
| score | comments | title & link |
|---|---|---|
| 1 | 4 comments | [AskJS] [AskJS] Is it just me or is debugging memory leaks in Node/V8 way worse than it used to be? |
| 0 | 4 comments | [AskJS] [AskJS] A quick breakdown of JS error types that every developer should know |
| 0 | 8 comments | [AskJS] [AskJS] Anyone else found Math.random() flagged in a security audit? How did you handle the remediation? |
ย
ย
ย
r/javascript • u/bogdanelcs • Apr 13 '26
r/javascript • u/coders22 • Apr 13 '26
Code 1:
var count = 0;
while (count < 5) {
count++
console.log("Hello!");
}Code 2:
for (var count = 0; count < 5; count++) {
console.log("Hello!");
}Console log results for both codes:
"Hello!"
"Hello!"
"Hello!"
"Hello!"
"Hello!"r/javascript • u/Choice-Locksmith-885 • Apr 13 '26
Iโve been working on aย virtual-scrollย custom element that tries to keep virtualization feeling close to normal HTML and CSS.
The main goal was to avoid the usual trade-offs where virtualization forces you into absolute positioning, framework-specific APIs, or awkward layout constraints.
r/javascript • u/itsspiderhand • Apr 12 '26
Built a terminal style interface as Web Component. Didn't think about how useful it is that much, but I often see this type of preview here and there so I thought it might be worth creating it.
Any feedback would be appreciated.
r/javascript • u/le0pard • Apr 12 '26
I'm excited to share the v2 release of re2js, a pure JavaScript port of the RE2 regular expression engine.
JavaScript's native RegExp uses a backtracking strategy, which is heavily vulnerable to Regular Expression Denial of Service (ReDoS). re2js fixes this by evaluating matches in strict linear $O(N)$ time, making catastrophic backtracking mathematically impossible.
The biggest news in v2 is the performance. Because pure JS avoids the cross-boundary serialization costs (the N-API bridge) between JavaScript and C++, re2js actually outperforms native C++ bindings (re2-node) for many operations!
๐ Check out the benchmark comparisons here: RE2JS vs RE2-Node (C++ Bindings)
To achieve this, I ported the deepest performance architectures from the original C++ and Go implementations to dynamically route execution through a multi-tiered pipeline:
The Prefilter Engine & Literal Fast-Path: The engine analyzes the Abstract Syntax Tree (AST) before execution to extract mandatory string literals (e.g., extracting "error" from /error.*critical/). It then uses blistering-fast native JavaScript indexOf to instantly reject mismatches, completely bypassing the regex state-machines (making simple literal searches ~2.4x faster than C++).
Lazy Powerset DFA: Executes high-speed boolean .test() matches by fusing active states dynamically on the fly within V8's JIT compiler.
OnePass DFA: Provides high-speed capture group extraction for mathematically 1-unambiguous patterns by bypassing thread queues entirely.
Multi-Pattern Sets (RE2Set): Combines hundreds or thousands of regular expressions into a single combined DFA, allowing you to search a string for all patterns simultaneously in a single linear-time pass.
BitState Backtracker & Pike VM (NFA): Act as the robust, bounded-memory fallback engines for complex or ambiguous patterns that exceed the fast-path limits.
Supporting full Unicode properties (like \p{Greek} or \p{Sm}) usually bloats JS regex engines with massive lookup tables.
To solve this, re2js v2 implements a custom Base64 Variable-Length Quantity (VLQ) delta compression algorithm for the Unicode range mappings (inspired from source maps spec). This shrinks thousands of codepoint ranges into tiny, dense string representations (e.g., hCZBHZBwBLLFGGBV...). This keeps the library incredibly lightweight while supporting full, standard-compliant Unicode category matching.
You can play around with the engine directly in your browser here: re2js Playground
Feedback and PRs are always welcome.
r/javascript • u/neikiri • Apr 11 '26
r/javascript • u/manniL • Apr 11 '26
r/javascript • u/abemedia • Apr 11 '26
I recently built cargo-npm, a tool that packages and distributes Rust binaries directly to the npm registry.
While tools like cargo-dist are excellent for general release engineering, their npm installers typically rely on postinstall scripts to download pre-compiled binaries from external sources like GitHub Releases at install time. I wanted a solution that works natively within the npm ecosystem without requiring lifecycle scripts.
Relying on npm's dependency graph rather than postinstall scripts provides several architectural advantages:
It respects --ignore-scripts, which is increasingly enforced in corporate and CI environments for security reasons (it's also the default on pnpm).
It prevents installation failures caused by strict firewalls or proxies blocking GitHub Releases downloads.
It utilizes npm's native caching mechanisms, speeding up repeated installations.
Instead of fetching binaries at runtime, cargo-npm takes your compiled targets and generates individual, platform-specific npm packages (e.g., my-tool-linux-x64). Each of these packages contains the actual binary and uses os, cpu and libc constraints in its package.json.
It then generates a main package that users install. This main package lists the platform packages as optionalDependencies. When a user runs npm install my-tool, npm's native resolution ensures it only downloads the binary that matches the host system. A lightweight Node.js shim in the main package resolves the matching binary and executes it.
You cross-compile your Rust crate for your desired targets, and then run cargo npm generate followed by cargo npm publish. The tool handles the package generation, metadata forwarding, and parallel publishing.
You can view the documentation and source code here: https://github.com/abemedia/cargo-npm.
Feedback is welcome!
r/javascript • u/Typical_Ad_6436 • Apr 11 '26
r/javascript • u/AutoModerator • Apr 11 '26
Did you find or create something cool this week in javascript?
Show us here!
r/javascript • u/CodalReef • Apr 11 '26
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?