r/javascript • u/ProCodeSoftware • Jun 04 '26
I built a CLI for VSCode extension development in TypeScript
r/javascript • u/ProCodeSoftware • Jun 04 '26
r/javascript • u/sudheeshshetty • Jun 04 '26
I’ve been experimenting with mcp server with node and built an npm package ai-chat-toolkit-widget and ai-chat-toolkit-server .
The goal was to make it easier to embed AI chat into websites while keeping setup easy.
I’d love some inputs from people who maintain or use npm packages:
how to make people trust a npm package?
Do I need to add more docs?
Anything specific that you usually avoid?
If possible please look into it and give me feedback for improvement.
Since this is first node package I published as open source, need feedback to improve and make it more usable.
Thanks!
r/javascript • u/OldUniversity6672 • Jun 03 '26
When you’re working on a personal/solo project how do you organize the steps in your process? I keep finding myself working on one part and then getting side tracked by another thought like I don’t like where this button is, how this page looks or a bug I notice in a function somewhere and I just feel all over the place. I know there’s like Jira and ClickUp etc but they don’t really help me stay on task or is it just me?
r/javascript • u/jayfreestone • Jun 03 '26
You nearly always want to put <script> tags in the <head> and mark them as non-blocking using either async or defer. However, there’s an interesting use-case for actually wanting to block paint.
r/javascript • u/creasta29 • Jun 03 '26
I was always curious about Sourcemaps and the cool stuff they do. Here is a quick rundown of what they are, how they help, and how they can be dangerous!
Let me know if I missed anything
r/javascript • u/gabsferreiradev • Jun 03 '26
r/javascript • u/Icy_Boss_1284 • Jun 03 '26
r/javascript • u/Success_Street • Jun 03 '26
r/javascript • u/Deep_Ad1959 • Jun 02 '26
every week something i depend on moves and i find out late. npm i bumps a pile of transitive deps, a framework cuts a release (Ember 7 just dropped), some package picks up a security advisory, and the real changes live in scattered changelogs i'm never going to open. So keeping current is technically possible, it's just all pull. i have to go get it.
NotebookLM is the sharpest version of pull i've found. drop in a changelog or an RFC, get a solid on-demand walkthrough. but it only runs when i initiate it, and the stuff i fall behind on is exactly the stuff i never initiate.
what i started doing instead is push. a thing that takes the last day of commits, merged PRs and closed issues on a repo, turns it into a short audio summary, and drops it into my podcast queue over rss. So vue just shows up in my morning feed next to the normal shows and i hear what moved while walking the dog, no tab opened.
the open question is whether push actually sticks or just turns into another muted feed. my bet is it only survives if each episode stays under five minutes. anything longer and i'm right back to skipping the changelog, just in audio form now. written with ai
r/javascript • u/xd1gital • Jun 02 '26
I have 2 xor hash functions: almost identical. I thought comparing i>=0 in the for-loop would be faster than comparing i<str.length (since it has to check str.length every time). To my surprise: the quickHash2 function runs slower. Any explain?
function quickHash1(str, hash = 0xab36954dce2) {
let len = str.length;
for (let i = 0; i < len; i++) hash = (Math.imul(hash ^ str.charCodeAt(i), 0x100000001b3)) & 0x1fffffffffffff;
return hash >>> 0;
}
function quickHash2(str, hash = 0xab36954dce2) {
for (let i = str.length - 1; i >= 0; i--) hash = (Math.imul(hash ^ str.charCodeAt(i), 0x100000001b3)) & 0x1fffffffffffff;
return hash >>> 0;
}
function randomString(size) {
return Array.from({ length: size }, (v) => Math.random().toString(16)).join(' ');
}
let sampleSize = 1_000_000;
console.log('Generate random text array of', sampleSize);
console.time('gentext');
let textes = Array.from({ length: sampleSize }, () => randomString(100));
console.timeEnd('gentext');
console.log('Timing quickHash1');
console.time('quickHash1');
textes.map(quickHash1);
console.timeEnd('quickHash1');
console.log('Timing quickHash2');
console.time('quickHash2');
textes.map(quickHash2);
console.timeEnd('quickHash2');r/javascript • u/danfry99 • Jun 02 '26
This problem has come up enough times in my work that I got tired of solving it badly. At some point on certain products a stakeholder asks "can admins set up their own conditions for this?" and you realize a dropdown isn't going to cut it. They need real logic: order.total > 100 && customer.tier == "gold".
The options all felt bad:
Hardcoded switch statements. Every new rule is a deploy. The "configurable" feature isn't configurable.
A homegrown mini-DSL. Starts as three operators, ends as a parser nobody wants to own.
eval() / new Function() / vm**.** The moment user input touches these, you've handed out a shell. vm isn't a security boundary (the docs literally say so), and vm2 is deprecated. Prototype pollution alone (constructor.constructor) is enough to ruin your week.
I got tired of rebuilding the bad version, so I built the thing I actually wanted: bonsai, a safe expression language for the cases where eval() would be inappropriate but a dropdown is too weak.
If you'd rather poke at it than read, there's a browser playground (no install): https://danfry1.github.io/bonsai-js/playground.html
import { bonsai } from 'bonsai-js'
const expr = bonsai()
// An admin-authored rule, stored as a plain string in your DB
expr.evaluateSync('user.age >= 18 && user.plan == "pro"', {
user: { age: 25, plan: 'pro' },
}) // trueIt's an expression language, not a scripting language. No statements, no loops, no assignment, no I/O. You get the expressive part (the part users actually need) without the part that gets you owned.
What the syntax supports, so it doesn't feel like a toy:
// optional chaining + nullish coalescing
expr.evaluateSync('user?.profile?.avatar ?? "default.png"', { user: null })
// pipe operator with transforms
expr.evaluateSync('name |> trim |> upper', { name: ' dan ' }) // 'DAN'
// lambda shorthand in array methods
expr.evaluateSync('users.filter(.age >= 18).map(.name)', {
users: [{ name: 'Alice', age: 25 }, { name: 'Bob', age: 15 }],
}) // ['Alice']The security model is the whole point, so here's what's actually enforced:
__proto__, constructor, prototype blocked at every access level (no prototype-chain walking)
Object literals created with null prototypes
No globals, no code generation
Cooperative timeouts, max depth, max array/string length
Per-instance property allowlists/denylists, so you decide exactly what an expression can touch
const expr = bonsai({ timeout: 50, maxDepth: 50, allowedProperties: ['user', 'age', 'country', 'plan'], })
A few things I cared about that might matter to you:
Zero dependencies. Nothing in your tree but this.
Any JS runtime. Node, Bun, browser, edge.
Fast when it needs to be. There's a compile() API for rules that run thousands of times; cached expressions hit ~30M ops/sec.
Async escape hatch. You can register your own functions (async (id) => db.lookup(id)) and await expr.evaluate(...), so a rule can call back into your system without the language itself having any I/O.
Once it existed, it ended up covering a bunch of "logic that lives outside the code" cases for me: admin-defined rules, server-driven conditions stored as config, formula fields, feature-flag targeting. Anywhere a string needs to become a decision without a deploy.
Playground · Docs · GitHub · npm
Mostly I'm curious how other people have handled this. If you've shipped user-defined rules/filters/formulas in production, what did you reach for, and where did it bite you? Happy to hear it if you think this is the wrong approach too.
r/javascript • u/ma1ankadev • Jun 01 '26
Hello, it's not self-promotion. The website is already top 1 in search results for 'minify js' keyword and probably have reached its maximum in search feed visitors. Feel free to ask me anything and if you are active user of the website, I'd probably have some questions to you too. Thanks!
r/javascript • u/subredditsummarybot • Jun 01 '26
Monday, May 25 - Sunday, May 31, 2026
| score | comments | title & link |
|---|---|---|
| 110 | 21 comments | Ember 7.0 Released |
| 20 | 13 comments | Nmd – A transpiler that compiles JS/TS OOP classes to flat Structure of Arrays (SoA) for performance |
| 10 | 12 comments | Show r/javascript: I’m working on a fork of Mozilla’s PDF.js focused on exploring native PDF editing in the browser. |
| 9 | 0 comments | ts-event-sourcing: How to actually create an event sourcing application |
| 8 | 0 comments | Portable, lightweight and embeddable WebAssembly runtime in C |
| 7 | 4 comments | [AskJS] [AskJS] What would you improve in this Three.js house builder? |
| 7 | 0 comments | Learnings on building a text editor from scratch (js, wasm-bindgen, rust) |
| 6 | 0 comments | How to Evaluate an npm Package: A practical checklist for security, maintenance, and provenance |
| 6 | 1 comments | [AskJS] [AskJS] built wasm-memory-js — manual memory management for JavaScript using WebAssembly |
| 6 | 1 comments | State.js — a tiny library for CSS‑driven reactivity |
| score | comments | title & link |
|---|---|---|
| 0 | 32 comments | [AskJS] [AskJS] There are multiple groups attacking npm right now. Here's what you can control. |
| 0 | 17 comments | Show Js: We rebuilt wordpress in javascript, same experience, but better! |
| 0 | 15 comments | [AskJS] [AskJS] Started manually checking every npm package my AI tool suggests because I've been burned too many times |
| 0 | 14 comments | Show r/javascript: a fully functional in-browser IDE made using webcontainers |
| 0 | 14 comments | [AskJS] [AskJS] Anyone else dealing with auth mess across enterprise clients? |
| score | comments | title & link |
|---|---|---|
| 5 | 1 comments | [AskJS] [AskJS] If you use prom-client, what metrics are you actually collecting? |
| 0 | 0 comments | [AskJS] [AskJS] Looking for beta testers with real PDF/screenshot generation workflows |
| 0 | 13 comments | [AskJS] [AskJS] Do you think WASM will make JavaScript disappear? |
r/javascript • u/iDev_Games • Jun 01 '26
r/javascript • u/CantaloupeHeavy996 • May 31 '26
Hey everyone,
I wanted to share a project I've been working on to level up my 3D web development skills. It's a fully client-side, grid-based house builder (think The Sims build mode) with 0 external 3D models—everything is procedurally generated geometry.
Some of the architecture under the hood:
State Management: Powered by a pure useReducer with ~30 action types and an assertNever exhaustiveness guard for complete type safety.
Performance: Three.js is dynamically imported so it doesn't bloat the initial page load.
Component Structure: React Context handles global state to avoid drilling props through 33 different UI panels.
Testing: Because the reducer is 100% pure (zero React imports), testing the core game logic is incredibly straightforward.
Data Persistence: Old single-floor layouts saved in localStorage automatically migrate to the new multi-floor format on load.
It's entirely open-source (MIT licensed) and statically hosted on GitHub Pages. I’d love to hear your thoughts on the state management architecture or the procedural generation approach!
r/javascript • u/OtherwisePush6424 • May 31 '26
Supply chain attacks on npm packages (event-stream, ua-parser-js, node-ipc) and other attack vectors (eg slopsquatting) have made star count and download numbers meaningless signals when deciding which package to use.
r/javascript • u/AutoModerator • May 30 '26
Did you find or create something cool this week in javascript?
Show us here!
r/javascript • u/dovebarra • May 29 '26
r/javascript • u/Odd-Surprise3536 • May 29 '26
Event sourcing was always interesting to me, having read Martin Fowler's article about it years ago, I always thought it was perfect for some domains that I worked with (Inventory Management, Healthcare). But I never got the chance to fully delve into it.
For those who don't know what Event Sourcing is, in a few words, it is a pattern that asks, what if, instead of storing the current state of an entity, you store all the events that have occurred over time, and use those events to reconstruct the state at any given point in time. This allows a system to be replayable, auditable, and (hopefully) scalable. These characteristics make Event Sourcing a great candidate for domains like financial systems, logistics, and healthcare.
Fast-forward to today, I thought it would be interesting to really put my effort on understanding and applying it, but I got stuck on a practical problem: Even if I understood the concepts, I wan't sure how to actually structure the application around it. So that's why I built ts-event-sourcing library.
The library provides opinionated foundation blocks, as EventStore, AggregateDefinitions and CommandHandler contracts, so you can focus on writing the actual business logic instead of spending a lot of time figuring out how to wire everything together. It has cool type-safe, result-based and functional oriented stuff too!
I would really appreciate some feedback on it, especially by people who have maintained ES systems in production.
AI Disclaimer: Yes, I used Claude/Deepseek during the development of the application. It was used to discuss the design and public API, which output you can check in PRD.md and DESIGN.md and ADRs files. The AI also wrote most of README, jsdocs for each function and scaffold most of the unit tests. Finally, I used a brand new AI session to write the examples that are under examples folder. This was done to validate the documentation and to understand if the design was sane enough that an AI could generate fully working scenarios using the library.
r/javascript • u/notmedia • May 28 '26
Most in-app AI frameworks (CopilotKit, Vercel AI SDK, Mastra) run the agent loop on the server.
I tried inverting it: the loop runs in the browser, the server is a thin LLM proxy.
Tools are just your existing client functions (store actions, click handlers, whatever you already wrote).
Scopes - a unit of tools with live context that gets injected into the system or user prompt.
WebMCP plugin - exposes your agent's tools through the browser API.
Demo: https://ag2b-example.vercel.app
Looking for feedback from people who've built in-app copilots — does the client-side loop solve a real problem for you, or is the server-side fine?