4 ms·
I do it this way with angular / express / server side templating. You render the title/ meta tags serverside for crawlers (fb, twitter, google), and drop your i
by teen 11y ago
I do it this way with angular / express / server side templating. You render the title/ meta tags serverside for crawlers (fb, twitter, google), and drop your initial request payloads in a script tag. Everything else is clientside. It took me a long time to set this up and get it right though. However, it's fast as hell, and really quick to develop on.
- mst 11y agoWorking on the assumption that the crawlers will index the JSON in the script tag?
- jrochkind1 11y agoCrawlers indexing is a different problem, and not the one the OP was talking about -- the OP's problem is specifically speed of first page display, and even more specifically speed of first page display due to having to make AJAX requests for data to display the first page. But crawlers and "single-page" Javascript apps are another potential problem, sure, although not the one the OP discussed. But wanting actual HTML in the original non-JS delivery for crawlers is I guess why people have followed the 'universal JS' approach instead of what we're talking about here. Other comments in this post suggest that Google, at least, does fine with Javascript-generated pages these days. I have no idea myself.
- mst 11y agoI was replying to a comment that specifically mentioned crawlers: https://news.ycombinator.com/item?id=10325666 https://news.ycombinator.com/item?id=10325666
- teen 11y agoJust catching up on this reply- yes- google has no problem rendering the json into readable html. Just using server side rendering for meta / title tags is the way to go (at least for now)
- teen 11y agoyes- and Google does this just fine. The meta tags are more for fb, slack, twitter, etc.