From the It-Depends-on-What-You're-Building department.
As a web developer you have a job:
- Display a certain amount of database data on the screen
- Do it as fast as possible
The first point is these days easily taken care of with the likes of Django or Rails which makes it über easy to write queries that you then use in templates to generate the HTML and voila you have a web page.
Here I have prepared three different versions of ways to display a bunch of information on the screen:
What you should note and take away from this little experimental playground:
All server-side work is done in Django but it's served straight out of memcache so it should be fast server-side.
The content is NOT important. It's just a list of blog posts and their categories and keywords.
View 1, 2 and 3 are all three imperfect versions but they illustrate the three major groups of solving the problem stated at the top of this blog post. The other views are attempts of optimizations.
Clearly the "visually fastest" version is the optimization version 5 which is a fork of version 2 which loads, on the server-side, everything that is above the fold and then take care of the content below the fold with AJAX.
See this visual comparison
Optimization version 4 was a silly optimization. It depends on the fact that JSON is more "compact" than HTML. When you Gzip the content, the difference in size doesn't matter anymore. However, it's an interesting technique because it means you can do all business logic rendering stuff in one language without having to depend on AJAX.
Open the various versions in your browser and try to "feel" how pages the load. Ask your inner gutteral heart which version you prefer; do you prefer a completely blank screen and a browser loading spinner or do you prefer to see some skeleton structure first whilst waiting for the bulk content comes in?
See this as a basis of thoughts and demonstration. Remember the very first sentence in this blog post.
Thank you, this was super useful . I usually work with Flask, and I always have the same concerns.