ah teaches web design & development (Debugging Day lecture)
Debugging Day
Lecture outline
As the title suggests we'll spend this lecture helping you debug your final projects in addition to covering some speed optimization. Lecture slides will be made available on the day of the lecture (November 21).
Page speed optimization
To get our pages to render as efficiently as possible, we need to keep in mind a couple of things:
- Render blocking
- Compression
- Critical rendering path
- Lazyloading
Render blocking
Anything that appears in the head
of our HTML must be loaded before the page can start to render.
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/grids.css">
<link rel="stylesheet" href="css/animations.css">
<link rel="stylesheet" href="css/jquery.ui.css">
<link rel="stylesheet" href="css/lightbox.css">
<script src="js/jquery.ui.js"></script>
<script src="js/popover.js"></script>
<script src="js/interface.js"></script></head>
Compression
"Minifying" your files
Using tools such as preprocessing we can remove all the extra spaces and comments in our files and deploy them online. We can also use such tools to to reduce requests.
/* We can set up preprocessing to combine files */
@import "main";
@import "grids";
@import "animations";
Critical render path
If we are getting into extensive page-speed optimization, we begin considering what is absolutely necessary for the user to get first (when they access the page), as opposed to what can wait until later.
<head>
<style>
<!-- Here we put in the 'critical' CSS for the page -->
</style>
<!-- Here we put 'non-critical' CSS for the page (i.e. fonts, animations -->)
<link rel="preload" href="/css/non-critical.css" as="style"></head>
Lazyloading
Lazyloading allows us to defer the loading of images until (and if) the user scrolls to an image on the page.
<img src="image.jpg" loading="lazy" height="230" width="1800" alt="...">
Next week
We will have two former-SIAT guests attending for critiques. Please arrive on-time with your project ready to go.