Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
construct that HTML document with JavaScript and after that hand it over to the browser. This can be experienced as a slight delay on the first page load.
Old code bases can always have the problem of being badly maintained and non-existing coding convention, no proper error reporting and stuck on an old language version. But you can mitigate that by using a good error reporting tool like Sentry (https://sentry.io/) or similar. When adding new views you could use a micro framework for those new views only and keep the old code as is, Slim framework could be an option for that.
I work with PHP professionally I always opt for server side rendering, it is faster to develop and easier to maintain. Main reason for that is that you already have all data available server side. When doing client side all that data needs to be exposed in an API that you need to design, write and maintain. Things has a tendency to be duplicated on both the server and the client. Many underestimate this cost.
When I need some dynamic updates of a component on the page I use JavaScript to solve that specific case only, not the entire page. To minimize what the JavaScript needs to do (fetch new data, render it to HTML and the put it on the page) it is better to deliver it as HTML fragment from the API endpoint directly rather than JSON, you avoid unnecessary JSON encode/decode step by doing that and you can just take the HTML fragment from the ajax call and insert it onto the page. By doing it like this you can reuse the same backend components when rendering the entire page or just a part of a page. It just how they are delivered to the page that differs. There is even a JavaScript library that can do all that work fetch and swap for you https://htmx.org/
With the htmx library you could also use that for page navigating on the site too if you want it more fluid.
construct that HTML document with JavaScript and after that hand it over to the browser. This can be experienced as a slight delay on the first page load.
Old code bases can always have the problem of being badly maintained and non-existing coding convention, no proper error reporting and stuck on an old language version. But you can mitigate that by using a good error reporting tool like Sentry (https://sentry.io/) or similar. When adding new views you could use a micro framework for those new views only and keep the old code as is, Slim framework could be an option for that.
I work with PHP professionally I always opt for server side rendering, it is faster to develop and easier to maintain. Main reason for that is that you already have all data available server side. When doing client side all that data needs to be exposed in an API that you need to design, write and maintain. Things has a tendency to be duplicated on both the server and the client. Many underestimate this cost.
When I need some dynamic updates of a component on the page I use JavaScript to solve that specific case only, not the entire page. To minimize what the JavaScript needs to do (fetch new data, render it to HTML and the put it on the page) it is better to deliver it as HTML fragment from the API endpoint directly rather than JSON, you avoid unnecessary JSON encode/decode step by doing that and you can just take the HTML fragment from the ajax call and insert it onto the page. By doing it like this you can reuse the same backend components when rendering the entire page or just a part of a page. It just how they are delivered to the page that differs. There is even a JavaScript library that can do all that work fetch and swap for you https://htmx.org/
With the htmx library you could also use that for page navigating on the site too if you want it more fluid.
Related posts
- Introducing Sailhouse, the easiest way to send events ⛵️
- Firebase Analytics Alternative for Kid's Category iOS App
- Building a Production-Ready Web App with T3 Stack
- How to Handle N+1 Queries for Optimal Database Performance in Django?
- Next.js Error Monitoring with Sentry: Enhancing Your Application’s Reliability