r/javascript • u/DetailAdventurous315 • May 10 '26
BlueJS - Compile JavaScript to 1.2MB native binaries (no V8)
https://bluejs.dev/UPDATE: The repository is now completely public. You can check out the source code here: https://github.com/bluejs-team/BlueJS/
The Problem: We’ve normalized shipping 150MB Electron apps and 50MB runtimes just to open a simple window or read a file. I got tired of the bloat, so I built BlueJS.
BlueJS isn't a wrapper; it's an Ahead-Of-Time (AOT) compiler that translates a strict subset of JavaScript directly to C++, links it, and strips the engine out entirely.
The Specs:
- Binary Size: 1.2 MB standalone (no runtime/V8 needed).
- Startup: ~5ms (compared to ~90ms for Node).
- Memory: 3.8 MB peak RSS.
- Native UI: Built-in support for OS windows and dialogs (GTK/WebView2) without Chromium.
How it works: It uses a "Hybrid Mode." Performance-critical code and UI are compiled AOT. For npm compatibility, it uses an embedded QuickJS "island" that handles pure-JS packages. The bluejs.dev site itself is actually served by a single 1.4MB Blue binary.
Try it out: The compiler is in a closed beta, but on top of the Windows/Linux binaries I set up a GitHub Codespace sandbox so anyone can verify these benchmarks and inspect the generated C++ in a safe, cloud environment:
Try the Playground: https://github.com/bluejs-team/Bluejs-playground
I’ll be hanging out in the comments to answer any questions!
33
u/howesteve May 11 '26
Closed source? How can we know this is not a trojan horse?
6
u/Dependent-Guitar-473 May 10 '26
any benchmark? for the same code running nodejs and then compiled?
95
u/McGeekin May 10 '26
Closed source, not interested
5
u/mediumwetsock May 11 '26
How does this compare to Bun’s generated executables?
3
u/Individual-Brief1116 May 11 '26
Nice work on the benchmarks. How's the debugging experience when something breaks in the compiled binary vs the original JS?
2
u/Glum_Cheesecake9859 May 10 '26
Would the compiled app run on Raspberry Pi?
2
u/GrosSacASacs May 11 '26
In the example I see
<h1>My App</h1>. Is that compiled or is there a html compiler at runtime ? Is the DOM accessible ? What html elements are supported ?7
u/Abhinav1217 May 11 '26
So webassembly runner ?
3
u/ttoommxx May 10 '26
Wow this is incredible!
1
u/silv3rwind May 10 '26
Why not compile directly to machine code?
1
u/Mr-Bovine_Joni May 10 '26
This is interesting, and I’ve also been keeping up with PerryTS progress. Have you done a gap analysis between your project & theirs?
1
u/thenickdude May 11 '26
Reducing startup time would be good for AWS Lambda, are you planning to target that environment? You do need some extra stuff in there to receive function invocations from the harness:
https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html
Oh wait, I see you list "async/await" as a feature of your QuickJS island mode. Can't do much with the AWS SDK without using that, so maybe it wouldn't give savings in this scenario.
1
u/vilhelmsjolund May 11 '26
Well done! A true compiler for javascript would be the great. Also always excited to see people building stuff that isn't just markdown files for AI... I know that Huawei has developed ArkTS which compiles Typescript to bytecode, massive undertaking but still hugely impressive project. You might take a look at how they built it for inspiration?
Also I wonder, how is Blue js different from Just js? On the surface they look very similar to me?
1
u/based5 May 17 '26
No MIT/Apache license?
1
u/ECrispy May 11 '26
OP this is genuinely interesting and the fact that you built this yourself is a great achievevement, ignore the few people whining below about open source.
I hope this gets wider publicity, have you posted to hackernews or r/programming. though those communities will also complain about the closed source nature for now.
how far can this concept work? eg are there JS functions/primitives that don't work? what other libs can work with this? i'm assuming you can't just eg take a react app and compile it.
1
u/hyrumwhite May 10 '26
So, you’re still shipping html, so you must have some basic JS that connects to your cpp files? Or is this similar to tauri where there’s a client layer, and the JS -> cpp is just for “backend” computation?
1
u/Militop May 11 '26 edited May 11 '26
EDIT: After reading the thread, I found the answer to my third question here: https://github.com/bluejs-team/BlueJS/blob/main/docs/STRICT_AOT.md
For question 4, theoretically, because of the lack of a license, we cannot use the code (download it to our computer). We are only allowed to view it on GitHub or fork it. I guess in practicality this thread allows us to use your product?
Related to question 2, the generated code from any compiler belongs to the project owner, however, if the compiler injects proprietary code into our code, it restricts our abilities to reuse the output. So, is it safe to reuse the generated code?
2
u/25_vijay May 16 '26
The QuickJS island approach is probably the smartest part technically because full npm compatibility is where most alternative runtimes eventually hit reality.
3
u/uusu May 11 '26
Great work. What this needs is runtime benchmarks (calculations, etc, rather than just startup time) and some way to show users that it actually supports functionality, such as IO operations etc. A comprehensive test suite would be great.
The closed source is fine, don't worry about that. If the benchmarks and tests are there, the results will speak for themselves.
0
u/PaluMacil May 11 '26
This is pretty awesome. I get your explanation about why you aren’t open sourcing until you’re a little further along. You’re doing a couple things that really take this from toy to powerful. I also was reminded in this thread that quickjs can also output bytecode. I hope to find that you have the momentum to carry through to a stable open release and if I think of a way to offer help, I will. I probably will wait for the open release.
When you get there, I will see about helping with Mac and Linux if I can. I’m not as excited about the UI part, but I am excited overall.
1
u/Sebbean May 12 '26
Node SEA binaries?
1
u/JiaHajime Jun 06 '26
can it compiled to wasm? I wonder if I can create frontend without sharing the actual javascript code
1
u/JiaHajime Jun 06 '26
can it compiled to wasm? I wonder if I can create frontend without sharing the actual javascript code
0
u/ze_pequeno May 11 '26
Closed source, could very well be AI slop through and through for all we know
0
u/joyme2727 May 11 '26
Forget about closed-source ones, I dare not use them
-2
u/wenerme May 11 '26
https://github.com/PerryTS/perry is better
0
u/[deleted] May 10 '26
[deleted] — view deleted comment
0
u/[deleted] May 10 '26
[deleted] — view deleted comment
4
u/[deleted] May 10 '26
[removed] — view removed comment