# Optimizing performance for big app? (React, Svelte, Solidjs...)

**URL:** <https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738>\
**Category:** Tutorials and tips\
**Tags:** react, svelte, solidjs\
**Created:** [May 21, 2024, 8:02pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738 "2024-05-21T20:02:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [May 21, 2024, 8:02pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/1 "2024-05-21T20:02:28Z")

</div>

Hello everyone,

Currently, we have a react app running with babylonjs, managed state, and all is good… but, once a lot of nodes are involved, that reflects back on the state (changes, reactivity, memory, fps…) then it all becomes a lesser desirable experience.

That being said, would love to hear your thoughts about 3 things:

## 1. Optimizing babylonjs for react

How would you go about it ? I see that the inspector is written in react, any best practices in mind ?

## 2. React 19 seems great? does Babylon compile?

React 19 seems to be promising a lot of cool optimizations to many problems we have, just by virtue of using a compiler. seems like a stretch, but did anyone investigate how that might have bad side effects ?

## 3. Changing the framework

yeah I know… react is not a framework…  
Jokes aside, what do you think of Svelte or Solidjs? has anyone tried it? does it… work (with the compilation model)?

* * *

thanks a lot for your thoughts folks! happy coding!

---

<div class="post-metadata">

**Author:** ![j-te](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/j-te/32/37194_2.png) [@j-te](https://forum.babylonjs.com/u/j-te)\
**Post date:** [May 21, 2024, 9:05pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/2 "2024-05-21T21:05:22Z")

</div>

If your app is not heavily UI focused then using Babylonjs GUI may be satisfactory. The use of “frameworks” may bog-down the JS thread if state and updates are unmanaged.

In terms of state and managing your variables effectively: If using React, I like to keep Babylon refs right at the top of the app and the canvas outside of state updates and avoid binding React props/render updates. Create a top-level actions class/function that Babylonjs code can subscribe to, and execute when the scene is ready. What worked really well for me is using `setInterval` which executes React updates in a busy Babylonjs scene. This custom ActionsManager was a lazy but effective way to manage React updates. It can be useful if you want to display lots of information on the screen, from your scene. You can decide **when** React evaluates the render update.

If you have a lot of scripting you can consider putting Babylonjs and your game code on a Web Worker and keep React at the front. Not yet don’t this myself though, just an idea.

Also, Vite is great to use.

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [May 21, 2024, 9:06pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/3 "2024-05-21T21:06:03Z")

</div>

I use React and React Native with Babylon.js and Babylon Native in my day job. I’ve never been a huge fan of React if I’m honest and we do have to jump through a lot of hoops to eke the best performance out of it. Ideally you want your UI framework to get out of the way, leaving more cycles for 3D rendering. React, in my experience, gets in the way more often than it should.

I’ve never used Solid but Svelte is great - small, fast, compile away, no virtual DOM, surgical updates, less boilerplate, simply more fun. Svelte is my go to these days for personal projects, is a joy to use, and works a treat with Babylon.js.

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [May 21, 2024, 9:07pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/4 "2024-05-21T21:07:57Z")

</div>

> [@j-te](#):
>
> Also, Vite is great to use.

I second that. Vite is awesome …

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [May 21, 2024, 10:06pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/5 "2024-05-21T22:06:03Z")

</div>

Thanks a lot for your thorough answer @j-te !!

well, for one, it is indeed UI-heavy so GUI is not gonna cut it, second, I like the “reactivity” react provides tbh (and all of its ecosystem is really hard to let go, unless for something close to it)

> `useEffect`? wish Unity had that! state management is much cleaner in TS than what used to do back in my C# days with those static classes…

> (slight tangent, let’s all sit and agree that the web stack frankenstein’s monster isn’t helping)

That said, the performance hit is extremely noticeable… 😕

I’ll def consider testing the web worker fix!

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [May 21, 2024, 10:09pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/6 "2024-05-21T22:09:41Z")

</div>

thanks for the answer @inteja !!

I do concur, concerning your assessment of React!

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/c/4cbd37cebfa9eec267434685edf6ad61cab80af2.jpeg)

Great to hear that Svelte is working for you! that breathes a sigh of relief for me tbh! do you have maybe a boiler plate on git to look at? you kinda got me more excited for it haha

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [May 21, 2024, 10:36pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/7 "2024-05-21T22:36:42Z")

</div>

> [@feuerstein](#):
>
> do you have maybe a boiler plate on git to look at?

Not at the moment, but I’ll see what I can do.

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [May 22, 2024, 11:19am UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/8 "2024-05-22T11:19:37Z")

</div>

I’ll prototype something this weekend and post it, might be helpful for whomever reads the forum.

Side question, any favorite UI libraries for svelte ?

---

<div class="post-metadata">

**Author:** ![j-te](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/j-te/32/37194_2.png) [@j-te](https://forum.babylonjs.com/u/j-te)\
**Post date:** [May 22, 2024, 12:33pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/9 "2024-05-22T12:33:35Z")

</div>

The quickest, smallest package, no dependencies, no licence issues (including optional dependencies like icons and fonts). This is important for Babylonjs ofc.

Bootstrap? MUI?

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [May 22, 2024, 1:05pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/10 "2024-05-22T13:05:40Z")

</div>

the smallest package indeed, after all the goal is to get out of the way of BJS.

MUI is such a pain to customize. I did some research on the best way UI libs for svelte… and I am realizing that there is no escaping tailwind in modern day frontend dev …

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [May 22, 2024, 1:56pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/11 "2024-05-22T13:56:00Z")

</div>

You may try to create a custom solution with reusable Web Components - [Web Components - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)

---

<div class="post-metadata">

**Author:** ![j-te](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/j-te/32/37194_2.png) [@j-te](https://forum.babylonjs.com/u/j-te)\
**Post date:** [May 22, 2024, 3:17pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/12 "2024-05-22T15:17:58Z")

</div>

Personally I don’t love any of the most popular UI packages. I’m sure there may be a minimum library that purely focuses on **accessibility** , with no animations or effects. I like the idea of using Web Components! My latest projects I’ve avoided UI libraries and built my own components. Maybe start with this for your template which I’m sure can be styled by a single css file.

Sometimes while typing you just think why don’t I _do a Google!_ 😆

> **[A11Y Design System](https://design.ipedis.com/)**

---

<div class="post-metadata">

**Author:** ![shaderbytes](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/shaderbytes/32/174_2.png) [@shaderbytes](https://forum.babylonjs.com/u/shaderbytes)\
**Post date:** [May 22, 2024, 4:24pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/13 "2024-05-22T16:24:57Z")

</div>

I had a look at the link you posted and while it does seem to be good there is some “design dogma” in there. eg stating when not to use a checkbox… for binary decisions , use a toggle instead.

I personally have no problem using a single checkbox for a binary decision 😉

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/a/daf9be5f03a2a895eb2b47aaf47025b0c7f1fca5.png)

“expand scorecards” - could a toggle work , yes. did I want to use a toggle - no. I like the minimal look of the checkbox. I have not had a single user not know what to do with it … or complain about it.

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [May 22, 2024, 9:00pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/14 "2024-05-22T21:00:04Z")

</div>

I am curious to hear the team’s take on this, given that they chose react for the inspector ( @sebavan I see you there 😛 )

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [May 22, 2024, 9:39pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/15 "2024-05-22T21:39:45Z")

</div>

React is the natural, safe choice for many projects - there’s a lot of experienced React developers who know how to get the most out of it, and it’s not going away anytime soon. I think it’s a classic case of “no one ever got fired for buying IBM”. As much as Svelte and Solid are great, they are relative newcomers compared to React, Angular and Vue, and corporate decision makers are less inclined to take a risk on new tech unless there’s a compelling business case for it.

---

<div class="post-metadata">

**Author:** ![feuerstein](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/feuerstein/32/26127_2.png) [@feuerstein](https://forum.babylonjs.com/u/feuerstein)\
**Post date:** [May 22, 2024, 9:52pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/16 "2024-05-22T21:52:56Z")

</div>

was def my rational at the start of the project. makes a lot of sense. Let’s hope the future of web isn’t “just” react

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [May 22, 2024, 10:21pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/17 "2024-05-22T22:21:10Z")

</div>

Bits UI might be a good option for Svelte lightweight accessible UI components:

> **[Introduction - Bits UI](https://www.bits-ui.com/docs/introduction)**
>
> Headless components for Svelte.

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [May 22, 2024, 10:31pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/18 "2024-05-22T22:31:37Z")

</div>

During new project development I use [lil-gui](https://lil-gui.georgealways.com/) (a maintained fork of [dat.gui](https://github.com/dataarts/dat.gui)). It’s great for rapid development iteration, but not suitable for the final polished UI.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [May 22, 2024, 11:11pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/19 "2024-05-22T23:11:52Z")

</div>

Tweakpane is also very handy for these purposes - [GitHub - cocopon/tweakpane: 🎛 Compact GUI for fine-tuning parameters and monitoring value changes](https://github.com/cocopon/tweakpane)

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [May 22, 2024, 11:47pm UTC](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738/20 "2024-05-22T23:47:02Z")

</div>

Nice! I hadn’t seen that one @labris.

[Next page](https://forum.babylonjs.com/t/optimizing-performance-for-big-app-react-svelte-solidjs/50738.md?page=2)
