DEV Community

Cover image for Static Site Generators
Gary Bell
Gary Bell

Posted on • Originally published at garybell.co.uk

Static Site Generators

There is more and more focus on the performance of a website, and the effect performance has on search engine rankings.
Performance is the first metric loaded by Google's lighthouse audit.
The obvious reason why this is the case, is that Google wants to get the information to users as fast as possible.

The ultimate goal for any website is to get 4x100 ratings across the lighthouse audit, both on desktop and mobile.
Getting to that rating isn't always easy. Performance is the hardest to hit (in my opinion).

At the time of writing, the performance metric for my website homepage was sitting at 91/100.
My desktop rating

On mobile, the story is different. It's a much lower at 75/100.
Mobile lighthouse performance

Where's the Bottleneck

The slow part of most sites is due to the CMS in the background.
A lot of the time taken for a page to load is the communication between the CMS code and the database.
In a lot of cases this requires requests across the network to communicate with the database.
The returned data then need to be processed to generate the page content, which can then be returned to the user.
Each of these steps takes time.

If you can remove some of those steps, then the speed of the site will naturally improve.
This is where a static site generator comes in.

These remove the requirement to perform some of the steps.
Specifically any of the database and processing work.
It does this by building the page once, and storing it as a html file on the webserver.
This means the visitor is served the information they requested directly, because the page which would be built from the CMS at each request is already generated in full.

There are a lot of options out there if you want to use a static site generator.
A list of 314 (probably not even comprehensive) is available on the jamstack website.
I'll be taking a look at a few of the PHP based ones in a future edition.
For now, I'll let you go and marvel in amazement at how many options there actually are for static site generation (and that doesn't count hand-crafting the HTML).

Top comments (4)

Collapse
 
cwraytech profile image
Christopher Wray

What PHP static site generators are you looking at?

Collapse
 
_garybell profile image
Gary Bell

All in good time. That's a future post.

There's a lot of pretty good ones. My main problem is the scheduling of posts.

Collapse
 
cwraytech profile image
Christopher Wray • Edited

Hmm yeah. What I do is send a web hook to my frontend server whenever content is updated. I am wondering if you could do that with php by a schedule post add on or something.

Thread Thread
 
_garybell profile image
Gary Bell

Something like that, or modify a builder to only publish on or after the post's date.