84 Replies
im dead
what's your tech stack?
html css js
i hated react js
after i used it
js as in, pure js?
yup
preventDefault() stops the default behavior.
wtf
that's one tiny tool
is that it
not always, but somewhat yes
damn
pretty sure links wont work with preventDefault()
but that's to implement it the awful way
does it always work in cases like clicking links to other pages in the same webapp
like home about contact etc
that's a big "depends"
Oops I didn’t see the link in the question
Sorry 🙌🏻
don't prevent ahrefs 😮
use a button
are you making a single page or multi page site?
huh
im making multi page site
are you okay working with old tech?
😳
if its not bad practice
sure
you can use an iframe with the target set to the iframe
that's it
it's not efficient, but works
<iframe> tag?
whats the example you are trying to do?
navigation
where i click on home about contact etc buttons
or rather whats the issue not reloading the page on navigation.
But that is how navigation works
and the page gets loaded without reloading
you click the link... new page loads
What do you mean by not reloading??
When you click links, either you go to new page, or you load that link on same page.
What is it that you want ??
i was told that a good and modern website doesnt get reloaded when we click on a link
thats bullshit
don't listen to that person ever again
that's bullshit indeed
i mean we go to new page but the page doesnt get reloaded, im not sure if i was precise
What you are asking for is Client Side Routing
and without a fallback is the curse of React and whats wrong with Modern web ... change my mind
soo i wont have to worry about page reloading when sending user to another page through the navigation bar?
no
that is how the browser works
damn
that is how 70% of website work
If you’re going to a new page then how will you show your data in the page without it loading ?
they got me worrying about things that dont matter
sessions
If you want both I would look into SvelteKit >.>;; (imo works the best for ssr/static/csr combos)
or, you dont need to know any data
for example, for a blog, there's no data to be saved
yea if you are not trying to save some client side state its pointless
oh
well not pointless but not an issue xD
what if theres data to be saved
even then you can pass query params and use URL as state
url === best state
also, if you have a static page that's being served by a cdn, it's so stupid fast it makes no sense to even think about not reloading the page
unless you had animations or client side state 😄
i wanted the site to be flexible
incase in future the site gets complicated
what do you want the site to be about?
I'd say you need to research about webpages more
Like how they have and do work
im not making a specific site
im just learning how to make advanced and modern websites
then you won't get a specific answer for you, just general advice that may or may not apply to you
even for practice, it's good to have an idea of what you want to do
so no matter what type of website we are making, the page reloading when we click a link is never an issue?
I wouldn't worry about that untill you need too
or can answer that question for yourself
Then you will know
Don't learn by trying to bullet proof yourself, you will still just shoot yourself in the foot.
what if that need comes pretty soon, i will have to learn that at some point
it wont
and when it does you will know
when the need comes, you will learn it then
damn
does it come in handy when creating really complex websites?
not at all
i never had the absolute need for it
oh
someone really got in your head 😄
lol yeah
probably a React fanboi
🤢
and also a client could never complain about the website i created for them reloading when clicking on links?
no a client don't know dick half the time
they want something to work and work well.
yoo ur actually right, they hated plain html css js and probably used react or something similar
half?
almost never
So don't mistake me... understanding why is important. I use SvelteKit because it lets me do it all really easy.
seriously, there's stuff like blogger
wikipedia reloads with every click
the minecraft wiki as well
70% of websites probably reload
😄
there's lost of super famous websites that reload
oh
nice
bro
we need to do something about people who avoid plain html css js and stuff
one thing you might need is to do not reload the page when submitting a form
cuz they also want others to do the same
but that's the only "need"
I would make sure you understand what SSR/CSRendering/CSRouting/SSG are 😄
Cause like what that React lover probably never made clear is they were using it for SPA/CSR...
which for most websites (not webapps) is just terrible
like LinkedIn is the biggest POS
ok so the page does not reload... but it has a 20sec loading state on first load..
Moving the spinner from your browser to inside your page does not change the fact you have to load it 😄
that's the part that people don't think about: the loading state
they optimize the site to do not reload, but then you click a link and still takes a fair bit to load
not to mention this
also, for SEO, it is pretty sketchy
and then you take it all away from the browser... so you have to (or the fraemwork) has to remake the behavior.
like history api?
something as simple as back button
oh god
the push state and the bullshit and the horrible crap...
implementing all that yourself, correctly, is absolutely hell
seriously, reloading the page is perfectly fine
there is nothing wrong with it
with good caching, it may even be faster!
oh, and something else: anytime you prevent a page load, you have to handle initializing and de-initializing all events and elements and everything
for example, you initialize a datepicker
on loading the new page, you may need to destroy it before you delete the element
thanks for the help guys
i learned alot
you're welcome