DEV Community

Cover image for Leaving electron.js to the past.
Akash Pattanaik
Akash Pattanaik

Posted on

Leaving electron.js to the past.

So, I recently started using tauri because electron.js was no longer working on my pc... I was amazed to see the release build size of the tauri app.
It was way smaller than expected.

Size Comparison

Electron.JS Tauri
62.5mb 4.32mb

These are the sized of installers for windows. The project was just a basic hello world displaying page.

So as you can see, Tauri is the next desktop framework for webdevs... Electron.JS is nothing compared to Tauri.
Tauri by default provides various templates for new projects like vanilla.js, react, svelte.js, vue.js and a lot more in the future. The tauri devs are also working on bringing Tauri to Android and IOS.

Tauri depends upon Microsoft Edge Runtime2 and not bulky core apps like Electron.JS depends on chromium.

Getting started with Tauri

This is for windows only, get your OS instructions on tauri.studio

This will make your ready for developing in tauri...

For Further Understanding, Check Out The Docs

Discussion (26)

Collapse
stevepryde profile image
Steve Pryde

Tauri depends upon Microsoft Edge Runtime2 and not bulky core apps like Electron.JS depends on chromium.

Actually, WebView2 uses the default rendering engine provided by the OS, which on Windows is now chromium (Edge) and on MacOS is webkit (safari). On Linux it will be either webkit or chromium depending on whether you're using Gtk or Qt.

The size of the binary is much smaller with Tauri, but the actual memory footprint while the app is running will be about the same, since (on Windows at least) you're still running chromium to render your app.

That said, Tauri itself is written in Rust and the back-end is likely faster than Electron. It's also simpler for your app to communicate with the back-end with Tauri, in my opinion.

Collapse
akashpattnaik profile image
Akash Pattanaik Author

written in Rust

That's what makes the app faster and thats all that matters...

Collapse
ricobrase profile image
Rico Brase

That's what makes the app faster and thats all that matters...

I tend to disagree.
It also comes with a particular disadvantage: You have absolutely NO control over the webengine used to render your application.

Just go back in time a few years, when Internet Explorer was still the default browser on Windows and it powered the WebViews in Windows as well.
Users of Electron apps could enjoy some fantastic modern applications, while Tauri apps (assuming Tauri would've existed back then, of course) would have to limit their functionality to be compatible with Internet Explorer (and/or ship polyfills, yikes!).

While this problem isn't as dramatic as it used to be, there are still some differences between the implemented features in each browser and you as an app developer rely on the OS developers to update their webrendering engine in order to fix (security) bugs, ship new features, etc.

With Electron, you ship the rendering engine by yourself. YOU have the control over the version of the rendering engine you are shipping. What features it has implemented, what bugs are fixes, what security flaws are closed.

Speed is a pretty significant factor, but it's absolutely not the single most important thing.

As in every project you should analyze which technology suits your project the most.

Thread Thread
stevepryde profile image
Steve Pryde

Agreed.

I think Tauri has its place but if it came with an option to always bundle chromium instead of relying on webview then I'd probably choose that option every time.

Thread Thread
joeschr profile image
JoeSchr

You mean like electron does? We have gone full circle...

Thread Thread
stevepryde profile image
Steve Pryde

Exactly. I don't have any issue with electron bundling chromium.

But Tauri being in Rust is nicer for the backend.

Collapse
duridah profile image
durid-ah

I agree that still having chromium run like that can be a pain, but wouldn't the reliance on webview mean that multiple apps on tauri would use one instance instead of each one having it embedded into the app?

Collapse
stevepryde profile image
Steve Pryde

You save on binary size but remember chromium runs each page in its own process anyway.

I'm actually not sure if parts of the webview renderer are shared. There are obvious security reasons why you might not want this. But if someone knows the finer details of how this works I'd be keen to know.

I'm a huge fan of tauri, having used it recently and found it to mostly just work. It allowed me to write a desktop app in rust without using electron :D

Thread Thread
qm3ster profile image
Mihail Malo

Even if absolutely no runtime state is shared between consumers, the filesystem-backed executable code of the webview is, which also means it's going to end up in cache more often vs running four applications using four separate but barely distinguishable versions of chromium.

Collapse
veresp87 profile image
Peter Vereš • Edited on

Clearly you are just posting a big statement with a big title without basic knowledge of what are you talking about. Stating that this is the next framework just because of saving few megabytes od space is nonsense.

Collapse
abdullaniyaz12 profile image
Abdulla Niyaz

More like throwing a frustration at electron xd,

Collapse
akashpattnaik profile image
Akash Pattanaik Author

thats exactly the case cause my pc doesn't work with electeron.js.

Collapse
ansonh profile image
Anson Heung

Tauri ships with much less bloat than Electron for a simple Hello World program, but I think it's still too early to say that Tauri will definitely replace Electron. Nonetheless, it's very exciting to see a new alternative to Electron :)

Collapse
urielsouza29 profile image
Uriel dos Santos Souza • Edited on

Alternatives!

NW.js (Similar to electron, provides Source code protection)
DeskGap (bundles a Node.js runtime and leaves the HTML rendering to the operating system‘s webview)
Neutralinojs (chromium module is replaced with either user’s web browser or built-in browser component. Node run-time is replaced with a lightweight web server which exposes native OS functionality)
Proton Native (does the same to desktop that React Native did to mobile, based on github.com/parro-it/libui-node)
React Native Desktop (Cross-platform React Native Desktop port based on Qt framework)
Vuido (creating native desktop applications based on Vue.js, based on github.com/parro-it/libui-node)
NodeGui (powered by Qt5, NodeGui-React, Vue NodeGui, Svelte-NodeGui)
reactxp (library for cross-platform app development using React and React Native)
quasar (Vue.js based framework, which lets web developer to quickly create responsive websites/apps)
nidium
electrino
graffiti

Sciter.JS (Is a 5MB HTML/CSS/JS (ES6) runtime aimed as a direct Electron replacement)

github.com/sudhakar3697/electron-a...

Collapse
tbogard profile image
Erick Rodriguez

Here my problems with Tauri and it is the lack of backend: Tauri doesn't show options for you to build a business layer to manage subservices in your app. Copying a file? Saving a encoded audio from your app based on your configurations? Tauri can't do it. In comparison, electron has a main process that behaves like a backend with communication with your frontend.

I would change to Tauri if it offers a solid robust API for a main process, which don't have.

Collapse
stevepryde profile image
Steve Pryde

Couldn't you just code that up in rust and expose it as commands? Isn't that the intended use case? I thought electron changed recently to be more client/server and it became much more strict about communication between the two, for security reasons

Collapse
akashpattnaik profile image
Akash Pattanaik Author

That's possible, use the RUST API, just create your functions in rust and invoke them with window.__TAURI__.invoke('functionName')

Collapse
timleg002 profile image
Timotej Leginus

You don't need to invoke every command globally

Thread Thread
akashpattnaik profile image
Akash Pattanaik Author

Yeah, i was just giving an example, they have a pretty well documented docs at tauri.studio .

Collapse
duridah profile image
durid-ah

I hope that's part of their road map before hitting 1.0

Collapse
imagineeeinc profile image
Imagineee

i am very intrested in tauri and have high hopes for it and would like to switch to it, and later with the androida and ios support, the only reason i am reluctant is the fact there isn't a solid backend api, and its complex to setup for beginners web developers, though I am a rust developer so I have the toolchain installed for me.

And because I am a rust developer, i'd personaly use their wry engine, a striped down version of tauri,

if I ever want to build a rust powered app in which I have full control of the application backend.

Collapse
akashpattnaik profile image
Akash Pattanaik Author

That's true, it can be very confusing for webdevs to interact with the rust API of tauri. tbh, I am backend dev and I myself found it quite difficult to use the RUST API. But the pro's of Tauri are they have a great community. The discord community of tauri really helped me a lot.

The setup part will be hard to implement in existing projects, else new projects are pretty fast forward.

Collapse
patrickweb profile image
Patrick Waweru • Edited on

The main problem of electron is memory usage and after trying Tauri I realized that it doesn't solve this issue. The webview process that it relies on consumes almost just as much memory usage. Bundle size isn't that big of an issue with people downloading gigabytes of adobe and editing software, most people don't have as big of an issue on that.
With that said, I am yet to find the big selling point of Tauri.

Collapse
devlopr profile image
Aditya Mishra

Lol, try Neutralino JS.

I was working on a Sprite Editor using web technologies, I tried electron but electron simply eats my memory like piece of cake. I tried tauri but I didn't have any prior knowledge in rust so I left, then I tried Neutralino JS, and my Neutralino app release build weighed only 850KB, in which 700 KB was my JavaScript bundle.

Tho Neutralino is currently not mature enough like Tauri or electron, but it has a great potential.

Collapse
rohithaditya profile image
Rohithaditya

Haha Electron is also slow af....

Collapse
newdev0 profile image
Devesh Pal

Nice to meet ya!