SPA's and that first page load time

I’ve only built mobile apps so building a web based SPA is new to me, but it seems that one downside is that you’d need two round trips from the server to display content:

Round trip 1: get the client
Round trip 2: get the dynamic content

I’m wondering if having the first page be server rendered would be a good compromise. Then get the client and the dynamic content in one pass, and from then on make REST API calls to the server. Or is there a better way to do it?

That’s pretty much how it works subject to having to run node server side.

Keep in mind that due to the static nature of the SPA part after the initial visit the html / css / js is all cached. This means that on subsequent visits you’re basically just doing the dynamic content.

2 Likes

I’m watching some interesting developments around isomorphic javascript that addresses this issue. https://github.com/angular/universal comes to mind.

1 Like

I don’t think isomorphic javascript is going to have staying power. It seems most useful for the now-past era when Google’s spiders didn’t have native javascript ability so SPA’s got dinged in terms of SEO. So it’s most important use case has already passed.

But I do see the lingering need to reduce that first page load time. It would be for logged-out users by definition (if you were logged in, you’d have the client already). I would think that most frameworks use Redis to send the client and the (cached) dynamic content, but it seems like Phoenix is fast enough that no one uses Redis. So I believe that means using a standard server-rendered page.

Google is not the only search engine, and there are a lot of corner cases and limits on how google bot does index
SPAs