Previously

In the previous article I talked about how how the App Service was migrated to Docker to save costs in Azure.

Migrating to Docker

Intro & Goal

If at first you don't succeed, you probably forgot a ';' somewhere and you get a compilation error. That's the way it goes in software development. Nothing ever works from the first go. And that's alright, as long as everything works in the end and everyone is happy with the result.

But along the way, when you're programming something, a lot can change in a very short timespan. I had a colleague once, a very long time ago who said something I hadn't heard before. He said:

First make it work, then make it beautiful.

And this makes a lot of sence when you're developing software. When you're writing code, you're dumping every thought from your brain into your creative canvas, your IDE that is. It's like working on a draft document to catch the essence of the matter. And then, when you're satisfied with the end result, and everything works as it should, you rewrite it. Of course when you rewrite it afterwards, it should be clean and following all coding principles you always strive to respect. This is an elaborate subject on it's own, so I'm not going to deviate any further.

First make it work, than make it beautiful

That brings me to the next step in the development of the random-awesome-memory website, making things beautiful. I had a basic version, running from the default ASP.NET Core Razor Pages template integrated into Visual Studio. Everything was starting to get form and was up and running in Azure.

Now, I can understand that the definition of beauty is pretty subjective, so let's pretend I made it beautiful in my own way. I'm not a Web designer, although I've developed a lot of frontend applications and websites and not one ever compained.

Using a web template

Building a website layout can be a real challenge. Not only does everything have to look good, it also has to be technically correct and work on all the different types of devices. The responsiveness of the website alone can be a huge hassle. It takes a lot of time, which we don't always have.

So I decided to use a web template. Using a template is not a bad thing. Depending on the template you use, you can save a lot of time and therefore also money. You can also learn a lot from other developers on how they do things.

Canvas web template

I've been a fan of the Canvas template for years now. It's created by the company SemiColon. I found the template many many years ago on the website Envato ThemeForest and have already bought several licenses to develop websites for customers. And for random-awesome-memory website I'm not doing it differently. The regular license only costs 16$, which is all I need, and you get a 6 month support license accompanied with it.

The template has an extensive documentation website which is extremely helpful when implementing it. I can recommend this template when people want a website design really quickly without having any issues.

Finetuning

The required files are copied into the project as described in the getting started docs. The appropriate stylings of my choosing have been applied. I've filtered out the files I don't actively use and removed them. And that's about it for implementing the template. The last thing I need to do, is fine tune the performance of the website a little.

Website performance analyzers

There are a lot of online tools that allow you to test the performance of your website. I just Googled around a bit and found several results. GTMetrix looks like a decent one but in the past I had already used Google PageSpeed, so I checked this out thoroughly. In the end all these tools work in the same way anyway. You just fill in the url of your website, click Analyse or whatever and let the thing do it's magic. Then after a while you get a report of different topics on how to make your website better.

Processing the results

The report is pretty detailed. And the topics are extensive. I don't want to make my site perfect so I am going to take on the most frequent and easy to fix issues. These are the issues that always stand out the most:

Minify resources

When you're working with resource files in your website, which is actually always, they should always be as small as possible. I'm talking about CSS and javascript files. Before the user actually sees anything on your website, alle these files need to be downloaded and loaded by the browser. And of course, the bigger they are, the longer it takes. There are several techniques you can apply to make this process go faster. Minifying the resource files is one of these techniques. The minification process makes the files smaller by removing all the clutter and optimizing space.

Chrome Developer Documentation

Check Minify CSS to find out more about CSS minification

Chrome Developer Documentation

Check Minify Javascript to find out more about Javascript minification

You can minify your resource files in different ways. There are javascript compression tools at hand that allow you to create minified versions of your files when compiling. But I chose a different path. For ASP.NET Core there's a framework called WebOptimizer that allows you to minify your resources files at runtime through a middleware component. The installation and setup is easy so you don't have to worry about complicated build and configuration processes.

Enable text compression

Text compression is a technique to reduce the size of all your resources being sent over the wire. Apparently there's a .NET Core package that allows you to configure response compression, and it's conveniently called Microsoft.AspNetCore.ResponseCompression. This one also works through a middleware component that is easily installed and configured.

Chrome Developer Documentation

Check Enable text compression to find out more about text compression

ASP.NET Core Documentation

Check Response compression in ASP.NET Core to find out more about text compression in ASP.NET Core

Conclusion

If you make use of a web template, you can significantly reduce the amount of time and money spent on building a design for a website or application. The only thing you need to do is spend some time researching which template suits your needs. And great documentation can also mean a big deal.

But things don't end there of course. As always, the last thing to do is do some tweaking in performance. Many techniques are present, and by spending some time Googling around, you can quickly find out which are the most important to optimize your website. I was able to significantly reduce the load time of my random-awesome-memory website by applying just a few of these methods. You can always go a step further if you want, but that wasn't my goal here. I'm happy with the result. Now I can concentrate more on writing other articles.

Documentation Reference

Next

In the next article I'm going to discuss CI/CD, what it is and how it is used to make our lives easier.

Automating Website Deployment