3 ms·
One of the nice things about SPAs is that they allow navigation without the latency needed to re-load all assets. You can get there the old-fashioned way if al
by gwbas1c 4y ago
One of the nice things about SPAs is that they allow navigation without the latency needed to re-load all assets.
You can get there the old-fashioned way if all your assets are cached in the browser with long timeouts; but that implies that you're doing something like putting hashes in the asset URL and hashing them as part of your build process. (This, is why loading JavaScript and CSS from CDNs helps with performance.)
Otherwise, every time you navigate to a new page on a non-SPA, the browser still needs to send an IF-CHANGED-SINCE request to the server.
As a developer, though, the BIG drawback of SPAs is that they require building much stricter APIs for everything. In a traditional server-side HTML page, you can quickly prototype something where the code that's putting together the HTML has access to privileged data that you can't expose through an API. (IE, if you just need to prototype something, server-side HTML rendering code can directly talk to the database.)
- ptx 4y ago> One of the nice things about SPAs is that they allow navigation without the latency needed to re-load all assets. [...] You can get there the old-fashioned way if [...] you're doing something like putting hashes in the asset URL and hashing them as part of your build process. But that solves the problem, doesn't it? And it seems a lot simpler than implementing an SPA. Django has this feature built-in. You just have to enable ManifestStaticFilesStorage: https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage https://docs.djangoproject.com/en/4.2/ref/contrib/staticfile...
- gwbas1c 4y ago> And it seems a lot simpler than implementing an SPA Depends on your design goals. BTW, I'm not pro/against SPAs. It's just a tool, and like all tools, they have their advantages and disadvantages. In general, the fact that you can update the page without a server-side round trip is a major advantage. Granted, you can also do that with server-side rendering; but then your rendering logic is defined in two places.