Introduction
What is the difference between static and dynamic websites, and why do we care?
Think of a static website as a physical printed document. A direct mapping exists between the code you write to build the site and the result delivered to a client's browser. No extra processing or server-side logic is applied; the server returns the requested HTML document to the browser.
No matter how many times you visit the website (or print the document in our analogy), you get the same result.
Conversely, you could think of a dynamic website more akin to Television. There are different channels with different shows at different times in different parts of the world. Every time you turn on your Television, something else will be playing.
In real-world terms, a simple blog or menu for a restaurant could be a static website, whereas something like Facebook would be a dynamic website.
So, which should you choose for your next website project?
Static Websites - The Good ☀️
There are a lot of good reasons to adopt the static approach for your next project.
Less Overhead
There are fewer moving parts on a static website. There is no need for databases or a CMS; everything can be achieved with vanilla HTML, CSS, and JS.
More Speed with Less Effort
This is not to say that dynamic websites are not fast or that static sites can't be slow, but a static site requires much less work to make it fast. Due to its simple nature, it's much easier for pages to be cached, and there's less time spent "building" your page on the server at request time because everything is served as is.
More Secure
Because no code is being executed on the server and no database is involved, a static site is technically more secure, especially if you go a long time between changes/updates on your site.
Cheaper Hosting
Simplicity is coming to the rescue here again. It's cheaper and easier to host a static site with just some HTML files than hosting a dynamic site where you need to manage versions of PHP, install a CMS, set up a database, etc.
Static Websites - The Bad ⛈️
Static sites have some drawbacks though.
Steep Learning Curve for Non-Developers
If you're building a static site for yourself, you'll need to overcome the steep learning curve of writing HTML, CSS, and JS. If your eyes just glazed over reading that, then a static site is probably not what you want. But if you're up for a challenge and want to expand your skills, then you should definitely give it a go.
If you are a developer building a static site for a client, make sure you and your client are on the same page about what support for their new website looks like. There's nothing worse than needing to update your site only to find our the person who built it is long gone or has moved on.
Extra Work to Implement Dynamic Functionality
When there is no server-side processing, you can quickly find the edges of a static website. Think of simple things like a contact form that requires intervention from a server to process submitted data and send an email.
There are trivial ways around these kinds of issues, like EmailJS or Netlify Forms, but there are still extra steps, potential costs, or even technical debt that you might need to account for.
Working with Many Assets can be Tricky
Your website will likely have images, videos, file downloads, and more that you are now responsible for managing. It's not very practical to store a ton of pictures and files with the website code because there are limits to what you can put in source control.
Processing these assets every time you build your site can be slow and tedious. Many people reach for services like Imgix or Cloudinary to take some of the hard work out of managing images of various sizes on different devices but these are not without their cost.
Another option is to host your own image processing server like Thumbor, but you're paying with your time to deploy, maintain, and administer this service.
Dynamic Websites - The Good ☀️
Could a dynamic website solution be the right choice for you?
Everything in One Place
Generally, when building a dynamic website, you're working with a CMS (Content Management System) that comes out of the box with all the tools you need to get your website up and running. This is typically accessed from an admin portal where you can manage everything to do with your site in a straightforward interface. No code to be seen!
Great Editing Experience
The freedom you have to add, remove, and change content on your site in real time without waiting for your site to deploy and rebuild cannot be understated. Paired with great rich text editing, you can focus on writing content for your site and not code.
Plugins to the Rescue
No matter what CMS you end up using, there is typically a large plugin ecosystem that can fill in any gaps that the CMS might have. Everything from user logins on your site, sending emails, setting up a store, accepting payments, and more.
There is usually a plugin that can do what you want, and a community around it to support you. You can also build your own plugins to fit your unique requirements.
Dynamic Websites - The Bad ⛈️
Dynamic sites are not the best solution in all situations.
More Moving Parts
In the context of a dynamic site through a CMS, there are a few extra moving parts to be aware of, such as the CMS itself, which could require a license to use, a database that needs to be backed up, and the server itself, which you might need to maintain (depending on your hosting solution).
Updates
Unlike the static approach, you must keep up with updates to your CMS and server operating system (depending on hosting). These updates range from basic bug fixes to critical vulnerabilities that could make your website susceptible to hackers.
Tedious Local Development
Due to the database and server requirements to run your CMS, you might find that trying out new things on your own computer before you make them live can be tricky. There's a bit of a learning curve to set up your environment and get things running which is more complicated than just previewing your static site.
No Source Control
Another downside is that your content and configuration are typically stored in the database and not in your code. This means there is little to no ability to track your code in source control. This heavily depends on your CMS, though, as something like Craft does an amazing job keeping your templates, plugins, and configuration in code to make for easy source control.
So Which One Do I Choose???
Well, unfortunately, the answer (like most things) is "It depends". But here are some general rules.
- If you're a developer and are building something simple for yourself - Static site
- If you're building something for a client to maintain - Dynamic site
- If your site doesn't require any complex processing by a server - Static site
- If you want a full-featured editing experience or have multiple people working on the site at the same time - Dynamic site
- If you're looking for potentially cheaper hosting and less ongoing maintenance - Static site
- If you want something that works out of the box and has ready-made plugins to add functionality - Dynamic site
Conclusion
This article had a fair bit of content to cover, but hopefully, you found it educational and interesting.
Please contact us if you need help with your website, software, or IT services!