Separate HTML files VS injecting data via JSON for super similar content?

In project I'm doing, I have multiple pages that have exact same structure and differentiate only in pictures and text they use, but everything, structure vise is the same. My question is, what is standard and better for performance? When you click on the menu links, do I just point it towards separate html file, or do I just inject all that different info via JSON? Project allowes me to choose what I want to do, but I'm just wondering what is better! Cheers!
6 Replies
b1mind
b1mind2y ago
This is where component (UI frameworks) come into play really well. If you don't want to use a JS framework or similar, may I suggest learning a HTML template language. Like Pug, Nunjucks, Handlebars, etc. Not sure if that helps answer your questions directly but more indirectly xD You might want to visit what is SSR, SSG, SPA websites too. Make sure you understand how the platform works.
Dovah
DovahOP2y ago
I kinda just want to stick to Vanilla HTML/CSS/JS at the moment. xD Do you maybe know what would be more proper way of doing it between the 2 I mentioned?
b1mind
b1mind2y ago
HTML template lanuages are vanilla so to speak they are going to give you the power to create one header/nav for all pages though, when its compiled it will output vanilla html pages but save you from having to repeat the information over and over for each html page. Learning about compilers imo is a great intro to the rest too Also I feel learning a html template lang lends it self to learning UI frameworks later (as they will have templating of some sort too)
Dovah
DovahOP2y ago
Roger. I see how useful they are. But since JSON option exists, is it just slower and not as optimal as using HTML? Like how people say that if you can use CSS, use CSS instead of JS. (for simple animations and so for example)
b1mind
b1mind2y ago
So... yes and no again it depends how its build is. You can use JSON and SSG and the end result is static html But you can also load JSON via JS on each page which is not as good. If JS fails you have 0 content Also will be worse for performance yes I def would not use JSON to fill my navigations and such More for dynamic content coming from a CMS or Rest API.. but again not something I'm a fan of if its pure client side (most meta frameworks are backing away from Client side rendering period) Again I think its important for you to understand the difference between how these things work too. SSR, SSG, SPA(CSR) if you don't. So in your statement "CSS vs JS" yes you would want "just html vs json loading"
Dovah
DovahOP2y ago
Roger! Thanks for all the useful info! Cheers!
Want results from more Discord servers?
Add your server