I made an Electron app which doesn’t use gigabytes of RAM! Electron + SvelteKit + GQL

Innovative Electron Application Achieves Low Memory Usage with SvelteKit and GraphQL

In the world of desktop app development, performance and efficiency are often overlooked in favor of rapid deployment. However, Iโ€™ve recently developed an Electron-based application that defies this trend by maintaining minimal RAM consumptionโ€”even in complex scenarios. This achievement was possible by leveraging modern frameworks and thoughtful optimization strategies.

Rethinking Electron App Performance

Many Electron or Chromium-embedded applications tend to lag noticeably, primarily because they are prone to excessive repaints and rendering overhead. These frequent repaints can severely impact responsiveness, especially during intensive animations or visual effects.

The key to boosting performance is to minimize these repaints. Focus on using CSS transforms and opacity for animations, as they are GPU-accelerated and cost-effective. Additionally, enabling background throttling helps conserve resources when the app is running idle, providing ample headroom for advanced features.

Embracing SvelteKit for a Leaner Codebase

Unlike typical Electron apps that rely on heavy React frameworksโ€”such as Discord, which can consume hundreds of megabytes of RAMโ€”I chose SvelteKit for its lightweight and efficient rendering. This choice significantly reduces memory footprint and improves overall responsiveness.

Robust and Strict Stack

The application is built using TypeScript, adherence to a highly strict ESLint configuration, and GraphQL with urql and gql.tada. This combination enables seamless offline caching and data normalization, allowing users to interact with the app even without an internet connection. The UI components are primarily sourced from shadcn/svelte, ensuring a clean and modern interface.

Optimized Internal Architecture

All computationally intensive tasks are offloaded to Electronโ€™s utilityProcessโ€”a dedicated Node.js workerโ€”handled through a sophisticated inter-process communication (IPC) system. This design ensures the main thread remains responsive, further enhancing performance.

Advanced Features and Custom Enhancements

The app boasts several advanced features, such as a custom subtitle library, OpenGL shader-based video quality enhancement, and intelligent video compression artifact removal. These functionalities demonstrate the potential of combining hardware-accelerated graphics with optimized code to deliver high-quality media experiences without compromising system resources.

Final Thoughts

This project exemplifies how thoughtful architecture and modern web development techniques can transform Electron applications into efficient, resource-friendly tools. By focusing on reducing unnecessary repaints, selecting suitable frameworks, and offloading heavy tasks appropriately, developers can create high-performance desktop apps that rival native software in both capability and efficiency.


Interested in


Leave a Reply

Your email address will not be published. Required fields are marked *