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

Creating a Lightweight Electron Application with SvelteKit and GraphQL

In the realm of desktop application development, Electron has become a popular choice due to its ease of use and cross-platform capabilities. However, a common challenge faced by Electron developers is managing high memory consumption and sluggish performance, often caused by extensive repaints and inefficient rendering techniques.

Recently, I developed a custom Electron-based application that notably sidesteps these issues, delivering smooth performance without the hefty RAM footprint. The secret lies in strategic optimization and leveraging modern frameworks effectively.

Key Optimization Strategies

One major contributor to sluggish Electron apps is the frequent and costly repaints during animations or UI updates. To mitigate this, I focused on:

  • Minimizing repaint triggers by limiting animations to transform and opacity properties, which are GPU-accelerated and more lightweight.
  • Enabling background throttling to prevent unnecessary CPU and GPU usage when the app isn’t in the foreground.
  • Incorporating advanced visual effects like 3D animations and glowing CSS effectsโ€”which, surprisingly, are nearly costless in terms of performance when optimized correctly.

Framework and Technology Choices

For the frontend, I chose SvelteKit, which offers a highly efficient and minimal framework compared to other options like React. This decision comes from observing how heavy Electron appsโ€”such as popular applicationsโ€”often consume hundreds of megabytes just for JavaScript heap, largely due to less optimized frameworks.

The application’s backend stack includes:

  • TypeScript with a rigorously enforced ESLint configuration to ensure code quality.
  • GraphQL via urql and gql.tada for seamless offline caching, entity normalization, and overall data managementโ€”allowing the app to function smoothly even without network connectivity.
  • UI components built with shadcn/svelte, enabling a clean and modern interface.

Smart Resource Management

A notable design choice is offloading intensive tasks to Electron’s utilityProcess, which acts as a Node.js-only worker. This setup isolates heavy computations, maintaining a responsive UI by delegating work efficiently. Communication between processes is facilitated through sophisticated IPC mechanisms, enhancing performance and reliability.

Advanced Features

Beyond the core functionality, the application boasts several innovative features, including:

  • A custom subtitle system for media playback.
  • OpenGL shader-based video processing to mitigate compression artifacts in real-time, enhancing video quality.
  • An array of other performance-centric and aesthetic enhancements.

Final Thoughts

Optimizing Electron apps doesn’t need to be an overly complex or


Leave a Reply

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