#Changing pages causes no css for a second or two.

85 messages · Page 1 of 1 (latest)

silent crystal
#

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.

#

renderer.js:

willow briar
#

hmm does changeTheme func executes at first open of the app?

silent crystal
#

After a sec or 3 so no css for a while

#

Same issue

sly marsh
#

Browser need time to load css

#

Its expected behaviour

jovial bramble
#

Hi

silent crystal
# sly marsh Browser need time to load css

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.

sly marsh
#

If you dont what it, load css with page in head tag

silent crystal
#

you feel?

sly marsh
#

Thats how web work

#

Web servers able to use ssr

#

Or templates like ejs

#

With electron you need to do that manually

silent crystal
#

that made no sense at all

#

what is the solution?

sly marsh
#

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

silent crystal
#

huh????
its like 3 html files what

silent crystal
silent crystal
sly marsh
#

With js

sly marsh
silent crystal
#

Go on

sly marsh
#

Thats all

silent crystal
sly marsh
#

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

silent crystal
sly marsh
silent crystal
sly marsh
#

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...

silent crystal
#

because that's mad

sly marsh
#

hard for whom?

silent crystal
sly marsh
#

its not electron related

#

its web dev

silent crystal
#

but it can be done in electron, right?

sly marsh
#

yes

silent crystal
sly marsh
#

in any browser

#

no

silent crystal
#

can it be done in html, css, and vanilla js?

sly marsh
#

you can

silent crystal
#

AYO WHAT, IM DOING THAT

sly marsh
#

you doing that when dynamically changing css file

silent crystal
sly marsh
#

dynamically changing web page is spa in some cases

silent crystal
#

i would have to watch some vids before i speak

#

thank you so much for sharing this information with me

sly marsh
#

you can show login form in same page

#

by changing classes

silent crystal
#

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?

sly marsh
#

vanilla js is harder to manage

silent crystal
sly marsh
#

well, you have es imports

#

its simplify it a bit

#

spa usually load longer

#

because spa static js files may use 20-40mb

silent crystal
#

oooof

sly marsh
#

depends on the app

#

because everything comes from js

#

discord for example

#

is spa application

silent crystal
#

is it too late to change the whole app to be spa?

sly marsh
#

i dont know

#

you decide

silent crystal