Well, I have a theme system that uses multiple css files and then changes the css link element in the html based on what theme the user choses. The theme is stored in a mongoDB. Anyways, changing the theme colour changes instantly but changing pages makes.. the page wouldn't have css for a decent while then it finally loads the correct css file. Now this happens even if the theme hasn't been changed, even happens when you first open the app. I'm using electron vite with electron-builder.
#Changing pages causes no css for a second or two.
85 messages · Page 1 of 1 (latest)
hmm does changeTheme func executes at first open of the app?
Nah
After a sec or 3 so no css for a while
Same issue
Hi
There is a delay in loading CSS files when I switch pages in my Electron app, even when I haven't changed the theme. It's happening right from when I open the app, and it's really slowing things down. I've tried tweaking things. The way the theme thing works is it checks if there is a css link import and if there isnt then use the css link thing from the database which is the last remembered theme. Remember, this all works but there is a huge delay until it finally sets the new css link import from the database causing the page to be without any css for a very noticable amount of time when switching pages and when opening the app.
Ots expected behaviour for dynamic loading css
If you dont what it, load css with page in head tag
but then it would do something like, load green theme first because it's in the header and then after a delay it would finally load purple theme because that's the theme in the database
you feel?
Thats how web work
Web servers able to use ssr
Or templates like ejs
With electron you need to do that manually
Solution for what?
With css load delay?
Prepare page with proper css file
Or change the logic
I dont see any point to have multiple html pages
Somewhere in 2000 probably
Now you can do everything in one page
huh????
its like 3 html files what
you dont make sense bruh
but then there would still be a delay in making it the proper theme from the databse
You can dynamically change html content and do async background requests
With js
Then load data from database before page loading
Go on
Thats all
i need more than that to recode my whole code
More?
You can stop loading css files dynamically
And start using classes
Its faster then load css from scratch
Applying theme from preload
But it wont work with multiple pages
who on earth uses one page of html
every spa web apps
what's spa?
A single-page application (SPA) is a web application or website that interacts with the user by dynamically rewriting the current web page with new data from the web server, instead of the default method of a web browser loading entire new pages. The goal is faster transitions that make the website feel more like a native app.
In a SPA, a page r...
is that hard to do?
because that's mad
hard for whom?
well im still quite new to electron
but it can be done in electron, right?
yes
does it use any framework>
can it be done in html, css, and vanilla js?
you can
AYO WHAT, IM DOING THAT
you doing that when dynamically changing css file
wdym?
dynamically changing web page is spa in some cases
i would have to watch some vids before i speak
thank you so much for sharing this information with me
i feel like i've been living under a rock
is there pro's and con's or just pro's to using a spa?
vanilla js is harder to manage
only one i really know 😅
well, you have es imports
its simplify it a bit
spa usually load longer
because spa static js files may use 20-40mb
oooof
depends on the app
because everything comes from js
discord for example
is spa application
oooo
is it too late to change the whole app to be spa?
well i dont know how long it would take to convert it