4 ms·
This smells like over-engineering to me... In my experience, including rendering code both server-side and client-side is overkill. Just put all the rendering
by gmjoe 13y ago
This smells like over-engineering to me...
In my experience, including rendering code both server-side and client-side is overkill. Just put all the rendering and templating code client-side, period.
If you want your page to appear more quickly, then instead of loading content data with AJAX afterwards, just include JSON arrays of content directly within the HTML source itself, and use JavaScript to populate the page instantly, even as it loads.
(Obviously SEO is a different case, but there are tools built for that specifically.)
- frontendbeauty 13y agoThe approach you mention is much easier. However, it does make for slower perceived page load times, even when serializing JSON on the page, because the browser has to fetch, parse, and evaluate JS files before rendering the HTML into the document. This can take many hundreds of milliseconds, especially on mobile devices. In my experience, server-side rendering has led to a much better UX.
- sgdesign 13y agoI think the idea is that the same bit of code would be running both on the server and/or the client, depending on what you need. So it wouldn't require any more work on the end developer's part.