Hacker News new | ask | show | jobs
by freakynit 100 days ago
What happens when a user lands directly on 2nd or 3rd level page and have not "jumped" from 1st level page?
2 comments

Nothing special happens. µJS doesn't change anything for direct URL access. The server renders the full page as usual. µJS only intercepts navigation once it's initialized on the page. This is actually one of the advantages of this approach over a true SPA: every URL is a fully server-rendered page, so direct access, bookmarks, and sharing links all work out of the box.

Let's take an example. Say we have a website with 3 pages:

- Homepage "website.com/"

- Products "website.com/products"

- About "website.com/about"

Your browser can load any of these pages directly, as usual. But when you are on the homepage (for example) and you click on the "About" link, µJS load the "/about" URL, and replace the current page's `<body>` tag with the fetched page's one.

It's that simple.

Got it.. thanks..
The idea is that all the rendering is done server-side. So, the user always get a full page.
I feel like the browser should just do the same thing and this not be needed. E.g. seemless reload, keep scroll and focus state etc.
Hmm, got it. Thanks..