Hi everyone ![]()
This afternoon I worked on optimizing the frontend’s initial load, which I find can sometimes be a bit slow on mobile when the network is poor.
Improvements made :
Dynamic loading of heavy libraries :
- HLS.js (camera streaming)
- Leaflet (world map)
- ApexChart (charts)
These libraries are now only loaded when needed, lightening the main bundle.
Optimization of code splitting :
Some routes were not properly split, which unnecessarily increased the load by putting those routes’ code into the main JS bundle.
Result :
The main JS bundle goes from 2.94 MB to 694 KB, significantly reducing the initial load time.
Of course, nothing magic — the size removed from the main bundle is added to each route’s bundle, but the idea is that we only load what we need.
My goal is to have the dashboard load as fast as possible, because when I open Gladys on my phone, it’s often just to turn off a light, and if the load is slowed just because the frontend is loading unnecessary things, that’s a shame ![]()
Test and give your feedback !
I generated a Gladys Plus build with these improvements :
https://dynamically-import-librairie.gladys-plus.pages.dev
Looking forward to your impressions! ![]()