I am currently building a project, which is a survey creator. I created a Rest API on the backend with pure Node.js, and am also working on the frontend. Obviously, rendered pages need to be rendered depending whether a user is logged in or not, the current survey, etc. Normally, I use Express.js and integrate a template engine like Pug. However this project was designed to be as dependency-less as possible, so no template engines. Instead I simply send "static" HTML files to the client when the user sends a request. Then, on the frontend, I use template strings to "fill in" HTML like this:
document.querySelector('cta').insertAdjacentHTML('beforeend', `<div class="login" style=${isLoggedIn? "display: none;" : ""}`); // etc.
This made me wonder if I am really building a dynamic website. Technically, I am "dynamically" generating the HTML?
But there seem to be conflicting messages from the Wikipedia definition and a Udemy course, both which seem to say that dynamic websites are generated on the server side like this:
When user hits request:
Backend builds template --> compiled to html --> file served to user
The way I do it looks like this:
Html file served --> JavaScript generates html
The terminology is very important here - is my website dynamic or static?
from Are frontend templated websites dynamic or static?
No comments:
Post a Comment