Static, Dynamic, or Jamstack?

Web Dev


Static Sites

The simplest type of website, and the first that a web developer will learn to build, is a static website. We call these websites static sites because they contain static content. Meaning that they are made up of HTML files which are served directly to the client without any pre-processing. This makes them simple, secure, and fast but comes with some serious limitations.


For example, let's say you have a simple blogging website. You will need to create a separate HTML file for every blog post you want to publish on the site. Over time, this could mean you wind up with dozens or even hundreds of these static files. What if you decide you don't like the way these pages look and you want to change the layout? You would have to go through every single file editing them all one by one.


It's easy to see how this would become difficult to manage at scale. It would be much more ideal if you could have just one blog post template which all blog post pages are derived from. That way, if you wanted to change the layout of the blog post pages, you could just edit that one template file and the changes would be reflected on every blog post.

Dynamic Sites

That is the power of a dynamic website. A dynamic site uses a server-side programming language to pre-process the HTML files before sending them to the client's browser. This means that the server could, for example, retrieve some data from a database and inject that data into the HTML file before sending the file to the client.


If any users clicks on a link to view a blog post, you could send all those requests to the same template file along with an identifier for the specific blog post they want (like an ID or Title). The server will receive the request, get the blog post page template file, get the necessary data about the specific blog post from the database, inject that data into the template file, and then send that file to the client's browser. All blog post pages are derived from the same template file, so if you decide to change the layout of these pages you only have to do it once in the template file. That is one example, but a dynamic website architecture can also allow you to store and manage user accounts, display different content to different users and run ecommerce stores.


The downsides to a dynamic website are that the architecture is more complicated compared to a static site, it is less secure because many hacks take advantage of server-side processes that aren't a concern with a static site, and the site is slower because the HTML files are being pre-processed before they're sent to the client which takes some time. It is also harder to deploy a dynamic website since there is more infrastructure necessary.

Jamstack Sites

A Jamstack site is a kind of hybrid static-dynamic site that can give you some of the benefits of both architecture styles. The 'JAM' in jamstack stands for JavaScript, APIs, and markup. This is a regular static site, made up of HTML files, but it is able to generate dynamic content by levaraging Javascript APIs to fetch data on the client-side. This way, the jamstack site can generate dynamic content such as blog posts or user information without the need for a server-side language. This gives you the quick loading times, ease of deployment, and simple architecture of a static website coupled with the ability to display dynamic content.


The jamstack makes your site or app very modular, meaning that it is made up of interchangeable parts which can be replaced without affecting the other parts. For example, you might be handling blog posts via one API and handling user accounts via another API. If something goes wrong with one of those APIs and it needs to be replaced, that can be done without affecting the second API.


This is in direct contrast to building a website with something like a monolithic CMS where everything is handled within the same system. So, if there is a problem with part of the system, it might require drastic changes or you might just be out of luck. You can still use a CMS within a jamstack architecture but the CMS is just one part of the system, not the whole system.

Static vs. Dynamic vs. Jamstack

All that said, jamstack is not the end-all of web development, at least not yet. It still has limitations and there are still use cases where a more traditional dynamic site, using a server-side programming language connected a database, is the way to go. It is not about which type of website is best, it's about which is best for the job.


Here's my recommendataion. Anything simple enough that it can be built as a static site, should be. If dynamic content is a must, I would ask first if it can be accomplished the jamstack way. In most cases, that will be the simpler, more lightweight approach. Only in cases where it is the only way that works would I resort to a traditional dynamic site.