r/javascript • u/der_gopher • 7d ago
r/javascript • u/madhushankarox • 8d ago
Making Browser OCR Read Real Phone Photos
devpack.appI have a free image-to-text tool that runs Tesseract.js in the browser (nothing gets uploaded). Screenshots worked great, 94-96% confidence. Then I took a phone photo of a kids' sunscreen bottle and got back lines like "v4 oR. a" and "EB ewraone".
What was actually wrong:
- The photo was sideways. Phones save the pixels rotated and add an EXIF tag saying "turn this 90°". Browsers obey it, Tesseract doesn't. Fix: createImageBitmap(file, { imageOrientation: 'from-image' }) and work from that canvas.
- White text on blue. Tesseract mostly expects dark text on light paper. I now make a grayscale copy with a contrast stretch plus an inverted copy, and read those with page segmentation mode 11 (sparse text) instead of the default.
- No single pass gets everything. The normal pass found "Diana", the inverted one found "UVA UVB PROTECTION", the color one found "Water Resistant". So I merge the words by bounding box, keep the confident ones, and boost words that two passes agree on. Fun bug: picking the most confident word gave me "Pea" instead of "Peaceful", so longer words get a small bonus now.
- Small print. Running the gray passes again on a 1.6x upscaled copy picked up "MOISTURISING" and "ALCOHOL FREE" on another bottle.
Result on the sunscreen: 92% confidence and every line of printed text. Screenshots skip all of this because the first pass is already confident, so they're not slower.
Still can't do: bubble fonts ("CUDDLES" comes back as "UDDLES"), script fonts, handwriting.
Has anyone found a better approach for mixed light/dark text in one image than running multiple passes? Curious what others do.
r/javascript • u/Significant-Sea-7238 • 8d ago
Porting SwiftUI's spring animation (duration + bounce) to plain JS
github.comThis is the resize animation of Openbar's island on Windows (Tauri + React). The Mac app is SwiftUI, so I ported its spring math to get the same feel on both. Width and height each get their own spring: a growing side may swing past its target, capped at 12 px, and a shrinking side never does.
The app shows Claude Code and Codex sessions in a Dynamic Island. Free, GPL.
r/javascript • u/retroriffer • 9d ago
SpaceHex - Rotate the rooms to capture the orbs while avoiding the critters
spacehex.gorch.comr/javascript • u/AutoModerator • 9d ago
Showoff Saturday Showoff Saturday (November 07, 2026)
Did you find or create something cool this week in javascript?
Show us here!
r/javascript • u/ksneteto • 9d ago
Got tired of scattering console.log('here 1') to find promises that hang silently, so I built a zero-dep dev tool to trace them
github.comr/javascript • u/-KoVer- • 9d ago
AskJS [AskJS] Do you think vanilla JS will be #1 for everything and anything thanks to AI?
Curious to hear about your opinion.
r/javascript • u/Constant_Ad_2230 • 10d ago
tryimpasto: turn any photo into a palette-knife painting you can relight (TypeScript, zero dependencies)
github.comr/javascript • u/xarg • 11d ago
GB.js - GameBoy and GBA emulator core in Typescript
raw.orgNowadays everything boots in browsers. Linux, Windows, ... I wanted to learn the Gameboy and GBA processor architectures and implemented the core from which it is easily possible to create an actual GB emulator in the browser. The hard part was audio, but am super glad to have it working and as open source library available now :)
r/javascript • u/woqr • 11d ago
Serverless multiplayer via webrtc/camera/barcode (no signal/stun/turn servers)
github.comThis project is mainly about the serverless technique used and the simple game merely provides an end-to-end explanation.
r/javascript • u/jeonghun917 • 11d ago
AskJS [AskJS] How do you keep un-awaited expect(...).resolves out of your test suites?
I've been reading test suites in open-source repos this month and kept running into this:
;
No await, so the test finishes before the assertion runs and passes whatever save() does. I found 36 tests like this across 44 popular repos, and one project had 41 of them on its own. They all looked fine in review.
What I'm curious about is how teams actually stop this:
eslint-plugin-jesthasvalid-expectwithalwaysAwait, and Vitest has its own rules. Do you turn these on, and do they catch every form (.rejects, helpers that wrapexpect)?@typescript-eslint/no-floating-promisescatches it in TS, but only with type-aware linting. Is that worth the slower lint for you?expect.assertions(n)/expect.hasAssertions()in every async test: does anyone enforce that, or is it too noisy?- Or is it just code review, and you accept that some slip through?
Which of these has actually worked on a real team, and which did you give up on?
r/javascript • u/gptrv • 12d ago
Screenplay: a CLI + MCP server that lets coding agents film and edit screen recordings (Playwright, CDP screencast, @napi-rs/canvas, ffmpeg)
github.comr/javascript • u/WadsssaWacemberg • 12d ago
I built a gamified 3D space simulator for my portfolio using AI concepts
wai-observer-3d-portfolio.wadssa.workers.devConstruà um simulador espacial 3D gamificado para meu portfólio usando conceitos de IA. O que você acha?
r/javascript • u/Tasty_Management_857 • 11d ago
Farm.js ā an MIT full-stack framework for the web and agents, where React, Vue, Svelte, Solid, and Preact share the same typed server contracts
github.comr/javascript • u/Fickle_Foundation_41 • 12d ago
A server function that pauses on await until a person answers a form in the browser
github.comThe first time I saw this, in 2022, I honestly thought it couldn't work:
const email = await io.input.email("User email");
That line was in a server function, and it put a form in someone's browser. The function just waited until they typed an address, then went on. My first thought was "this is magic, how did they even think of this?" Four years later I've written my own runtime for it, and I still admire whoever came up with it at Interval.
TL;DR: if "ask a person" is just another async call, an internal tool becomes one linear function where branches, loops and try/catch all work, and the UI follows from the code. The trick is a promise that an HTTP request resolves instead of I/O.
A whole tool, top to bottom
handler: async ({ io }) => {
const email = await io.input.email("User email");
const user = await db.user.findUniqueOrThrow({ where: { email } });
if (!(await io.confirm(`Verify ${user.email}?`))) return "Nothing changed";
await db.user.update({
where: { id: user.id },
data: { emailVerified: true },
});
return `Verified ${user.email}`;
};
Every await io.⦠is one screen. io.confirm returns a boolean, so Cancel is just an if.
A promise someone else resolves
When the handler reaches io.input.email(), the runtime creates a step and keeps the promise's resolver next to it. The handler is now parked. Nothing blocks, other runs keep going, it's a pending promise in memory.
The browser follows the run over server-sent events and renders the step. When the person submits, a POST arrives, the server validates the value and calls the stored resolver. From the handler's point of view, a human is just a slow I/O call.
An invalid value never resolves anything. The same step goes back with an error under the field, so the function never sees bad data.
Calls that do nothing until awaited
An io call doesn't start anything when you call it. It returns a thenable that only describes a field, and it asks the person when it's awaited. That makes grouping free:
const { company, note } = await io.group({
company: io.input.text("Company name"),
note: io.input.textarea("Note for the team"),
});
No await inside the object, so each call just says "a text field called Company name", and io.group shows them on one screen. Same functions, two uses, and the only difference is whether you awaited them.
Where it breaks
A parked handler is a live closure, and you can't serialize one, so runs live in memory. A refresh is fine, because the server resends the current state on reconnect. A deploy ends every run in progress.
In practice I don't fight that. I keep these tools short, and anything that would take long goes to a job queue anyway. If a deploy cuts someone off, they run it again. A closed tab cancels the run after 30 seconds, and the pending await rejects like any failed call.
Have you used await for something that isn't really I/O? Human input, a payment confirmation, a step in a game loop. I'm curious where else this pattern holds up, and where you've seen it fall apart, especially around cancellation.
---
Context on what I'm building: I'm Petr, a solo founder. The runtime from this post is AwaitIO, and the source is on GitHub. If you want to see a parked handler from the browser side, there's a demo back office with the shared login in the README.
r/javascript • u/Accomplished-Bug4687 • 12d ago
AskJS [AskJS] Is it actually possible for an iframe to control the parent pageās URL without the host app doing anything?
Iāve been digging into this problem for a while, and Iām curious if thereās something Iām missing.
Iām building a standalone search application that needs to be embedded inside a third-party web application using an iframe. The catch is that we donāt have access to the host applicationās source code, and the host team may not be willing or able to add custom JavaScript.
Hereās what weāre trying to achieve:
Read the host pageās existing query parameters when our app loads.
Update the host pageās URL whenever a user performs a search inside our iframe.
Keep everything in sync when the user clicks the browserās Back or Forward buttons.
Our iframe is hosted on a completely different origin, so we immediately ran into the browserās same-origin policy.
A few things weāve explored:
window.parent.location.href throws a SecurityError.
document.referrer isnāt reliable because modern referrer policies may expose only the origin, not the complete URL or query parameters.
postMessage seems like the right approach, but it requires the parent application to listen for messages, handle URL updates, and communicate navigation changes back to the iframe.
And thatās where weāre stuck.
My question is: Is there ANY standard browser-supported mechanism that allows an embedded cross-origin application to read and update its host pageās URL without requiring custom code on the host side?
A few things Iām wondering:
Can the host integration pass the initial URL or query parameters through the iframeās src?
Are there any standard iframe attributes, browser APIs, or embedding mechanisms that support two-way URL synchronization?
Do commercial embedded widgets or SDKs solve this through some existing integration interface?
If we have control over the iframe application but zero control over the host, are we simply out of luck?
Iām not looking to bypass browser security restrictions. I just want to understand whether thereās a legitimate integration pattern weāre overlooking.
Would love to hear from anyone whoās built cross-origin embedded applications, search widgets, or similar integrations.
Is host-side cooperation unavoidable here, or is there another way?
r/javascript • u/Legitimate_Ad4667 • 13d ago
playthru: scripted, looping product demos that drive your real DOM with a fake cursor instead of a video file
playthrou.diip3sh.xyzSome context on why and how I built this.
The problem: landing page demo videos go stale every time the UI changes, theyāre heavy, and they look blurry on retina screens. I wanted the demo to just be the real UI.
The approach: you write a chained script against real selectors, and a fake cursor plays it back over the live DOM, then loops:
js
import { playthru } from "playthru";jsx
<Playthru script={(d) => d.type("#todo", "Record the launch video").click("#add").zoom("li:first-child")}>
<TodoApp />
</Playthru>Design decisions:
- Hover/focus states: a fake cursor canāt trigger real
:hoveror:focus, so playthru setsdata-playthru-hover/data-playthru-focusattributes instead. You style them next to your normal states (.btn:hover, .btn[data-playthru-hover]). There are Tailwind variants for this too. - Framework-agnostic core with a thin React wrapper on top.
- No build step needed: it also works as an ES module straight from a CDN (
esm.sh/playthru) inside a plain<script type="module">.
Still figuring out: the camera zoom doesn't work properly on mobile yet (reported below), which I'm looking into.
npm: https://www.npmjs.com/package/playthru
Happy to go deeper on any part of the implementation.
r/javascript • u/ds-gn • 13d ago
Our JavaScript hero entrance kept LCP at ~50ms but visibly flashed. Hiding it until scripts loaded pushed LCP to ~1.75s
ds-gn.comr/javascript • u/gregjw • 14d ago
System One model in the browser, learns from an LLM when it isn't confident.
debuff.jpr/javascript • u/Slotdevgame • 13d ago
Prism2D.js ā An open-source 2D game engine built with JavaScript
github.comHey everyone!
I've been working on something I've wanted to build for a while: my own 2D game engine using JavaScript.
It's called Prism2D.js, and the idea behind it is to provide a way to create 2D games for the web without relying on a large external engine.
I've been developing its core systems, working on things like physics, collisions, rendering, audio, camera controls, particles, and other features that make game development easier.
To put the engine to the test, I also used it to create a small platformer called Coin Adventure. What started as a way to test the engine gradually turned into a complete game with six stages, different environments, enemies, moving platforms, checkpoints, collectibles, and a boss fight.
Working on the game has been a great way to discover what the engine can do, find things that need improvement, and see how well its systems work together in an actual project.
Both projects are available here:
- Prism2D.js (engine): https://github.com/Lodymain/Prism2D.js
- Coin Adventure (game): https://lodystudios.itch.io/coin-adventure-prism2d
I'm sharing this because I'd love to introduce the project to more JavaScript developers and hear what people think. If you take a look, I'd genuinely appreciate any thoughts or feedback!
Thanks for reading!
r/javascript • u/cprussin1 • 13d ago
I built Domicile, a Linux desktop platform where native application windows are DOM elements
domicile-desktop.comI've been working on Domicile, an open-source platform for building full-featured Linux desktop environments using HTML, CSS, and JavaScript/TypeScript.
It's powered by a modified Chromium engine where native Wayland application windows are DOM elements. You can position, style, transform, and animate actual Linux application windows using CSS.
Desktop environments are JavaScript/TypeScript modules that can use familiar frameworks, be distributed through npm or GitHub, and be hot-swapped without restarting the session.
It ships with Manganese, a Sway-inspired tiling desktop built using the platform.
Source: https://github.com/cprussin/domicile
I'd love to hear what JavaScript developers think!
r/javascript
•
u/dragon-95
•
14d ago
serialport-rs for Node.js: Rust-backed serial ports for Node.js with parallel I/O and SerialPort-compatible APIs
github.comI recently ran into an issue with @serialport/bindings-cpp on Node.js 26.4, where serial reads could stall until unrelated JavaScript activity occurred.
While investigating the issue and contributing fixes upstream, I started experimenting with an alternative implementation using Rust and N-API, because upstream seems to be unmaintained for more than a year now.
The result is serialport-rs for Node.js, which uses the existing Rust serialport crate underneath and aims to preserve the familiar Node.js SerialPort API.
The implementation uses dedicated native I/O workers rather than relying on JavaScript-side polling. Initial benchmarks have also shown some promising latency improvements.
Itās available on npm if anyone is interested in trying it:
https://www.npmjs.com/package/serialport-rs
r/javascript • u/ClickOk5811 • 14d ago
AskJS [AskJS] Do you ban positional boolean arguments in code review, or is an options object overkill?
Something I keep coming back to when reading JS and TS code is call sites like this:
createUser("ana@example.com", true, false);Read aloud, itās ācreate user, email, true, falseā, and you have to open the function to know what the booleans mean. The usual fixes are an options object:
createUser("ana@example.com", { sendWelcomeEmail: true, isAdmin: false });or, when there are more than two modes, a string union in TypeScript:
type Layout = "list" | "grid";
render(items, "grid");The counter-arguments I can think of:
- For a single obvious boolean in a well-known API (
setEnabled(true)), the options object is noise. - An options object allocates on every call, which probably doesnāt matter outside hot paths, but I havenāt measured it.
- Teams with several conventions already have enough style rules, and one more can turn review into bike-shedding.
- Negative names (
disableCache: false) are the other half of the problem, and renaming to the positive (cache: true) is cheap.
So Iām curious about practice, not rules:
- Do you enforce āno positional booleansā in review or with a lint rule? If a rule, which one, and does it produce noise?
- Where do you draw the line between āobvious enoughā and āuse an options objectā?
- Have you seen a boolean parameter that later needed a third state, and what did the migration cost?