I am looking for a solution to start viewing a web page while the request is not complete. For example, with Express and EJS, if I query multiple data sources (which I do not have the mastery), I have to wait to retrieve all the data I need to use before “res.render” .
Is it possible to send the top of the page and then blocks one by one ?
Thank’s for your help !
Make a basic template and feed res.render() with this. That would be the first thing the user sees.
You have to code a client .js code (which you call with your ‘basic’ page). This one, on
document.readywill issue ajax calls to fetch the other pages. For that, you will need to enable other routes, each with their respective content.The callback of the ajax calls must have a way to append the retrieved content into your ‘basic page’.
That should do.
(Obviously, there are several ways to make this more complex and more professional, but methinks @LeGilles was looking for a ‘kickstart’).
Regards,
H.-