The project's README from github.com/thedaviddias/Front-End-Performance-Checklist. As one markdown file: README.md.
The only Front-End Performance Checklist that runs faster than the others!
Performance is a huge subject, but it's not always a "back-end" or an "admin" topic: it's a Front-End responsibility too. The Front-End Performance Checklist is an exhaustive list of elements you should check or at least be aware of, as a Front-End developer and apply to your project (personal and professional).
One simple rule: "Design and code with performance in mind"
Other Checklists:
[!TIP] ⭐️ I've recently launched UX Patterns for Devs and a curated list for indie developers, feel free to check it out! ⭐️
For each rule, you will have a paragraph explaining why this rule is important and how you can fix it. For more deep information, you should find links that will point to 🛠 tools, 📖 articles or 📹 medias that can complete the checklist.
All items in the Front-End Performance Checklist are essentials to achieve the highest performance score but you would find an indicator to help you to eventually prioritised some rules amount others. There are 3 levels of priority:
List of the tools you can use to test or monitor your website or application:
![html]
Minified HTML: ![medium] The HTML code is minified, comments, white spaces and new lines are removed from production files.
Why:
Removing all unnecessary spaces, comments and attributes will reduce the size of your HTML and speed up your site's page load times and obviously lighten the download for your user.
How:
Most of the frameworks have plugins to facilitate the minification of the webpages. You can use a bunch of NPM modules that can do the job for you automatically.
Place CSS tags always before JavaScript tags: ![high] Ensure that your CSS is always loaded before having JavaScript code.
<!-- Not recommended -->
<script src="jquery.js"></script>
<script src="foo.js"></script>
<link rel="stylesheet" href="foo.css" />
<!-- Recommended -->
<link rel="stylesheet" href="foo.css" />
<script src="jquery.js"></script>
<script src="foo.js"></script>
Why:
Having your CSS tags before any JavaScript enables better, parallel download which speed up browser rendering time.
How:
⁃ Ensure that
<link>and<style>in your<head>are always before your<script>.
Minimize the number of iframes: ![high] Use iframes only if you don't have any other technical possibility. Try to avoid iframes as much as you can.
Pre-load optimization with prefetch, dns-prefetch and prerender: ![low] Popular browsers can use directive on <link> tag and "rel" attribute with certain keywords to pre-load specific URLs.
Why:
Prefetching allows a browser to silently fetch the necessary resources needed to display content that a user might access in the near future. The browser is able to store these resources in its cache and speed up the way web pages load when they are using different domains for page resources. When a web page has finished loading and the idle time has passed, the browser begins downloading other resources. When a user go in a particular link (already prefetched), the content will be instantly served.
How:
⁃ Ensure that
<link>is in your<head>section.
![css]
Minification: ![high] All CSS files are minified, comments, white spaces and new lines are removed from production files.
Why:
When CSS files are minified, the content is loaded faster and less data is sent to the client. It's important to always minify CSS files in production. It is beneficial for the user as it is for any business who wants to lower bandwidth costs and lower resource usage.
How:
⁃ Use tools to minify your files automatically before or during your build or your deployment.
Concatenation: ![medium] CSS files are concatenated in a single file (Not always valid for HTTP/2).
<!-- Not recommended -->
<link rel="stylesheet" href="foo.css" />
<link rel="stylesheet" href="bar.css" />
<!-- Recommended -->
<link rel="stylesheet" href="foobar.css" />
Why:
If you are still using HTTP/1, you may need to still concatenate your files, it's less true if your server use HTTP/2 (tests should be made).
How:
⁃ Use online tool or any plugin before or during your build or your deployment to concatenate your files.
⁃ Ensure, of course, that concatenation does not break your project.
Non-blocking: ![high] CSS files need to be non-blocking to prevent the DOM from taking time to load.
<link
rel="preload"
href="global.min.css"
as="style"
onload="this.rel='stylesheet'"
/>
<noscript><link rel="stylesheet" href="global.min.css" /></noscript>
Why:
CSS files can block the page load and delay the rendering of your page. Using
preloadcan actually load the CSS files before the browser starts showing the content of the page.
How:
⁃ You need to add the
relattribute with thepreloadvalue and addas="style"on the<link>element.
Unused CSS: ![medium] Remove unused CSS selectors.
Why:
Removing unused CSS selectors can reduce the size of your files and then speed up the load of your assets.
How:
⁃ ⚠️ Always check if the framework CSS you want to use don't already has a reset / normalize code included. Sometimes you may not need everything that is inside your reset / normalize file.
CSS Critical: ![high] The CSS critical (or "above the fold") collects all the CSS used to render the visible portion of the page. It is embedded before your principal CSS call and between <style></style> in a single line (minified if possible).
Why:
Inlining critical CSS help to speed up the rendering of the web pages reducing the number of requests to the server.
How:
Generate the CSS critical with online tools or using a plugin like the one that Addy Osmani developed.
Embedded or inline CSS: ![high] Avoid using embed or inline CSS inside your <body> _(Not valid for HTTP/2)
Why:
One of the first reason it's because it's a good practice to separate content from design. It also helps you have a more maintainable code and keep your site accessible. But regarding performance, it's simply because it decreases the file-size of your HTML pages and the load time.
How:
Always use external stylesheets or embed CSS in your
<head>(and follow the others CSS performance rules)
Analyse stylesheets complexity: ![high] Analyzing your stylesheets can help you to flag issues, redundancies and duplicate CSS selectors.
Why:
Sometimes you may have redundancies or validation errors in your CSS, analysing your CSS files and removed these complexities can help you to speed up your CSS files (because your browser will read them faster)
How:
Your CSS should be organized, using a CSS preprocessor can help you with that. Some online tools listed below can also help you analysing and correct your code.
![fonts]
Webfont formats: ![medium] You are using WOFF2 on your web project or application.
Why:
According to Google, the WOFF 2.0 Web Font compression format offers 30% average gain over WOFF 1.0. It's then good to use WOFF 2.0, WOFF 1.0 as a fallback and TTF.
How:
Check before buying your new font that the provider gives you the WOFF2 format. If you are using a free font, you can always use Font Squirrel to generate all the formats you need.
Use preconnect to load your fonts faster: ![medium]
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
Why:
When you arrived on a website, your device needs to find out where your site lives and which server it needs to connect with. Your browser had to contact a DNS server and wait for the lookup complete before fetching the resource (fonts, CSS files...). Prefetches and preconnects allow the browser to lookup the DNS information and start establishing a TCP connection to the server hosting the font file. This provides a performance boost because by the time the browser gets around to parsing the css file with the font information and discovering it needs to request a font file from the server, it will already have pre-resolved the DNS information and have an open connection to the server ready in its connection pool.
How:
⁃ Before prefetching your webfonts, use webpagetest to evaluate your website
⁃ Look for teal colored DNS lookups and note the host that are being requested
⁃ Prefetch your webfonts in your<head>and add eventually these hostnames that you should prefetch too
Webfont size: ![medium] Webfont sizes don't exceed 300kb (all variants included)
Prevent Flash or Invisible Text: ![medium] Avoid transparent text until the Webfont is loaded
![images]
Images optimization: ![high] Your images are optimized, compressed without direct impact to the end user.
Why:
Optimized images load faster in your browser and consume less data.
How:
⁃ Try using CSS3 effects when it's possible (instead of a small image)
⁃ When it's possible, use fonts instead of text encoded in your images
⁃ Use SVG
⁃ Use a tool and specify a level compression under 85.
Images format: ![high] Choose your image format appropriately.
Why:
To ensure that your images don't slow your website, choose the format that will correspond to your image. If it's a photo, JPEG is most of the time more appropriate than PNG or GIF. But don't forget to look a the nex-gen formats which can reduce the size of your files. Each image format has pros and cons, it's important to know these to make the best choice possible.
How:
⁃ Use Lighthouse to identify which images can eventually use next-gen formats (like JPEG 2000m JPEG XR or WebP)
⁃ Compare different formats, sometimes using PNG8 is better than PNG16, sometimes it'