I am building a blog that displays content similar to how youTube does. I want to have my blog article in the center and a sidebar on the right. I want the sidebar to contain previews of several other articles that I have written along with their corresponding image (like the youTube layout). At the bottom of the sidebar, I want to have a button to load more content.

I am trying to brainstorm how I should deal with serving the sidebar content. I have thought of two ways of doing it but am not sure how efficient or standard they are. (Also this blog is in express btw)

  1. I can load a set amount of content before my express view is called. For example, I can query my db for 8 article previews and pass that with my view. e.g res.render("example.ejs", {articleTitles:[], pathToArticleImages:[]}

  2. I can load my express view without any of the sidebar content and then make an immediate ajax call to get content for the sidebar.

My question is which option seems more optimal? Is it better for the view to take longer to load but all content comes at once vs loading the article right away and then waiting for the sidebar content to arrive via ajax?

If both of my ideas suck, how can this best be accomplished? Thanks :)

New contributor
hibytfc is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • This question appears to be off-topic because it is about web development which is off-topic at Pro Webmasters. Web development questions may be asked at Stack Overflow but be sure to read their FAQ before posting to ensure your question meets their guidelines. In its current form, this question does not meet their guidelines.
    – John Conde
    Jan 14 at 14:56