My old website, 100/100 Page Speed Insights (desktop AND mobile), unique design
Tags: showdev, webdev, performance, javascript
Published: 2021-03-13 10:55:19

I thought I would show [my old website klu.io](https://klu.io) as it is about to be retired in the coming weeks but it has some interesting features I thought you all might like.

Unfortunately (for the site) just as I "finished" it (as it isn't finished 😋) a great opportunity presented itself and the site got forgotten about.

Every few months I pop on it and try to improve stuff (but normally end up breaking more things than I fix!) but other than that it has sat "unloved" for almost 2 years 😪

When I launch my new company and website in the next couple of weeks it will no longer be in use (I might leave it up for posterity but I won't be monitoring it anymore) so I thought I would give it a proper send off and see what people think of it.

I have learned a lot since it went live so there are loads of things I would do differently but despite that here are a few things that I am still quite proud of....

## Contents
- [Why did I build this site?](#why)
- [A unique design](#unique)
- [It gets top marks in Lighthouse](#lighthouse)
- [Security - it gets 125 / 100 in Mozilla Observatory](#security)
- [Accessibility](#accessibility)
- [What would I do differently?](#different)
- [Rounding Up](#roundingup)

<a name="why"></a>
## Why did I build this site?
I had become interested in the technical aspects of websites. I was mainly back-end focused but I really wanted to get into the front-end world due to accidentally stumbling into accessibility on a project. 

It may have started with accessibility and that is now one of my biggest passions, however it was one of those "down the rabbit hole" moments where accessibility and the technical aspects of HTML etc. lead me on to all technical aspects of front-end design.

It evolved into looking at best practices, speed etc. because of [Lighthouse](https://github.com/GoogleChrome/lighthouse). Then it lead onto security headers because of [Mozilla Observatory](https://observatory.mozilla.org/).

So it was built as a "technical showpiece", it isn't built for conversions, it isn't built for SEO, it is built purely to score well in synthetic tests and as a learning exercise. I would not recommend it to any clients let's put it that way!

Along the same lines the site works without JavaScript, just in case it fails for any reason and even works all the way back to IE9. Those were two restrictions I placed on myself just to add an extra challenge!

There are hundreds of things I would do differently now (especially when it comes to accessibility as ironically that is probably it's weakest point!), but it still "kicks arse" in synthetic tests (and in a lot of real world scenarios as a result).

Finally I was not much of a designer and if I wanted to venture into the front-end world that would have to change! I also got sick of seeing "bootstrap" websites that all looked the same so the first task was starting with a design that stood out.

<a name="unique"></a>
## A unique design
![Kluio website "what makes a great design"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xlvzs8h1998nrt64ua0g.jpg)

As I said, I wanted to challenge my design skills. I am not a designer so there are probably things that could be done better but every single asset you see is designed by me.

I took inspiration from a mobile game (see if you can name it in the comments) and set about emulating that style.

I can't remember where the little robot people idea came from but I always liked them as they were race neutral and that aligned with my remit of inclusion.

I really wanted a site with unusual aspects, yet again to stretch myself. The page shown above is the "what makes a great website" page on the site and that was the most interesting design challenge.

I wanted to try and tell a story with each image matching with each item that I believe makes a great website.

So I built up the landscape and then created different mini scenes that (kind of) represent the area of "what makes a great website".

For example the little robot painting the landscape for design.

![robot painting the landscape on an easel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjmvf4xwqp8vw6svls1v.jpg)

However as you can see a lot of the detail is lost when you are looking at the whole scene.

### Zooming in for detail
This is one thing that really challenged me at the time. I had spent all this time designing the assets but a lot of the detail just was not visible.

So I designed the page that when you clicked an item we zoom in on the part of the image that is applicable.

The challenging part was ensuring the image was located in the same place each time when zoomed in. 

![Zoomed in view of train on kluio website performance page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ovz7rbzzpvnozdi671op.gif)

In the end I just manually set up a coordinates system for `x`, `y` positions and `zoom` level. If I did this again I would just measure the containing rectangle and calculate the centre and size so I didn't have to manually set these, but yet again I was also still learning front-end so I hacked my way to a solution like all good (bad?) developers do!

### Animation
I could probably write several posts just on how I achieved each animation. From the [train smoke](https://klu.io/great-websites/speed) to the little [robot security guard destroying the invading virus](https://klu.io/great-websites/security) and the waterfall. If that interests people then let me know in the comments and I will write a post on them.

Someone could then probably write several posts on how to do it better 😋!

The main thing I wanted to make sure was that the animations could be easily switched off for people who have [vestibular disorders](https://vestibular.org/article/diagnosis-treatment/types-of-vestibular-disorders/) and may have set their preference for reduced motion  on the page (which we can ascertain from the [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion) media query).

As such the animation CSS ended up in a separate file, which made it really easy to manage and something I have adopted in all projects now. I then see if the media query matches in CSS and switch animations on if it doesn't (off by default in case JS fails).

Anyway that is all of the design stuff, as I said, not my strong suit. The really interesting part of the site is how it scores in synthetic tests.

<a name="lighthouse"></a>
## It gets top marks in Lighthouse
![100 on all Lighthouse Audits](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5qpjtzkl058cw89idid.jpg)

**Quick aside:** One thing I just found out today is if you get 100 / 100 across all 4 categories in Lighthouse, "fireworks" display on the Lighthouse results (that is what those strange coloured dots are on the image above!), that is something new!

### Speed
That scoring is for mobile, not desktop like most people who claim to get 100 out of 100 (it obviously gets 100 / 100 for desktop) for speed. 

It was my first time building a site designed for speed so I spent waaay too long optimising it, but always fun to get top marks.

Also, as I was less skilled back then, I focused purely on page size. 

Without analytics the whole site is less than 100kb down the wire!

Getting such a small page size involved several interesting tricks. The main trick being processing the SVGs I created with [SVG OMG](https://jakearchibald.github.io/svgomg/). This wiped about 80kb off the original images sizes.

#### Tiny JS payload
The next "trick" was not using jQuery. Now that isn't much of a trick but I always liked jQuery syntax.

As such I discovered a beautiful tiny library called [ki.js](https://github.com/dciccale/ki.js/).

With a couple of tweaks to make it usable in production and a load of extensions to add things like `.parent`, `.first` etc. I had something that worked (and worked all the way back to IE9, another requirement I had!) that was tiny (about 1kb)

This let me get the whole JavaScript for the site down to 7.3kb minified and gzipped.

#### Inlining the CSS
This used to work so much better but I broke it. 

Originally the site only inlined critical CSS and then had separate style sheets for anything not yet required. However I broke it a few months back so now it thinks everything is always above the fold and sends everything inline.

I will write a different post on that when I launch the new site as we did the same thing there, but figuring out a method to reliably find elements that are critical and inlining them was another fun exercise.

<a name="security"></a>
## Security - it gets 125 / 100 in Mozilla Observatory

![Mozilla Observatory 125 out of 100 score](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2j6c5db1jd92p3gj6ffb.jpg)

This was the other thing that took a **lot** of time to learn and adjust.

I wanted to learn about security headers to protect the site from XSS etc. 

So learning about [Strict-Transport-Security](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security) and the associated [HSTS preloading list](https://hstspreload.org/) was interesting.

Even more interesting was creating a [content security policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) that scored top marks as I had to completely rewrite some parts of the pages. 

For example no inline styles is a nightmare when working with SVGs as they define their styles within the SVG itself. I had to move all of the styles to a stylesheet and add classes to each and every path etc. That was horrendous!

The other issue was that I needed inline scripts on the page and inline CSS. So I had to learn about [CSP nonces](https://content-security-policy.com/nonce/) and then work out a way of adding those dynamically.

<a name="accessibility"></a>
## Accessibility
![Kluio Robot with guide dog and robot in wheelchair conversing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6hcq57ils3yq6ha1pb0.jpg)

As a first attempt at building an accessible website I still don't think I did badly.

However there are loads of things wrong. I don't trap focus correctly, the contact form errors do not report correctly, screen magnifier users may struggle with a couple of elements on the page etc.

With that being said I think the site would be usable by most users and would still be better than about 90% of sites out there.

The main thing I wanted to learn about on this site was setting up for `prefers-reduced-motion` as I mentioned previously and on that side of things it works well, switching off the animations if you have indicated you do not want them.

Accessibility is the main reason this site wasn't revamped for the new company and is being retired, there were too many design decisions that were not conducive to accessibility that would need completely rethinking.


<a name="differently"></a>
## What would I do differently?
Oh a lot of things!

The CSS relies way too heavily on `vw` and `vh` to position things for a start.

Secondly the JavaScript is messy and not very well thought out for extensibility. That is the reason things break on the site when I try to "fix" it, everything is too closely intertwined so changing one thing breaks another.

I wouldn't use Google Analytics, I have my own analytics package now which is far smaller and provides all the details I need.

I would put a lot more thought into accessibility before I started building the site. I made loads of mistakes that would be easy to remedy if I built the site again today but trying to reverse engineer it would be quite a large task. This is why I always say **put accessibility on your roadmap from day one** as one poor decision can lead to a lot of remedial work in the future. With that being said I know a lot more today then I did back then so I have to take that into account.

Above all I think I would spend a lot more time at the planning stage. I followed the "just do it" principle and it led to a lot of mess and mistakes. I would plan out the interactions on the page, how the page would behave with larger font sizes etc. 

If you take one thing away from this article it is that you should spend more time planning how the site will actually work and not just what it looks like and make sure that if you implement feature "X" it still allows you to meet your targets for accessibility, performance etc. rather than designing it and then trying to implement those things. 

<a name="roundingup"></a>
## Rounding Up
Anyway that is a brief overview of a site that I have yet see be beaten from a technical scoring perspective.

Looking back I can't believe how far I have improved in 2 years.

I regret never giving this site the "final polish" and publishing articles on it, even 2 years later I still like the site (which is unusual for me) as it is still pretty unique.

Let me know what you think (you can be critical and harsh, I learn better from criticism and it may give me ideas for future articles at the same time!)

**Finally, I am throwing down the gauntlet. Do you have a site that can beat this one on speed, accessibility etc? Please share it in the comments I would love to see it!**