3 ms·
It used to be impossible to link to specific page in a SPA without using hashes in the URL, but this problem has been solved years ago, and all modern browsers
by ngrilly 5y ago
It used to be impossible to link to specific page in a SPA without using hashes in the URL, but this problem has been solved years ago, and all modern browsers support it.
- denton-scratch 5y agoWhat's a "specific page" in the context of discussing single-page applications?
- hbn 5y agoIf you go to example.com/user/jim in your browser, it'll navigate to (presumably) the profile for the user with the handle "jim" Maybe I don't understand what you're asking. Browsers these days have functionality that enables SPAs to navigate between URLs, push/pop to and from the back history, etc. without full page reloads.
- denton-scratch 5y agoWell, example.com/user/jim looks to me like a Unique Resource Locator. If that's right, then what I'll get is a "page" (you could call it a resource). If the locator is really "unique", It'll be different from the page I get if I ask for example.com/user/jane, right? (modulo aliasing) Well if that's right, then this site is not a "single-page application". It has multiple pages with different URLs, and I don't know how that's different from any other website with server-side state. [Edited to mention state; state is irrelevant to whether its an MPA or an SPA, but without state it's hard to argue its an application at all]
- spurgu 5y agoI see the definition of SPA as a web app that doesn't require page reloading when navigating. So both a SPA an an MPA can have the same URL structure while the latter requires page refreshes when switching between them. I might be wrong.
- denton-scratch 5y agoI see. I guess I'd better inform myself better about the jargon. So without a page-refresh, does anything get stored in browser history? Does the back-button work?
- spurgu 5y agoTraditionally that's been an issue but nowadays there's the History API. https://developer.mozilla.org/en-US/docs/Web/API/History https://developer.mozilla.org/en-US/docs/Web/API/History
- hbn 5y agoCorrect. What I was trying to get across in my earlier reply is that a URL isn't quite treated the same as their name would imply these days. I could see why that might annoy purists, but these days there are browser APIs that enable modifying URLs (which modifies the "back" history) through Javascript, without actually doing a full reload of resources. So even though you're requesting a different address, you're technically not getting an entirely new "resource." No matter where you hit the address, you'll get the same base blob of HTML/css/js, but going to the URL directly will fire the proper navigation (through js) to get you to the spot you requested (which may involve loading different resources, dynamically). Hopefully that explanation makes sense