The Front-End Performance Checklist speeds up your web developments

An exhaustive list of all the elements that will speed up your current web developments and offer the best user experience.

David Dias
codeburst

--

You know Flash?… Well, now you can say “I’m the new Flash Dev 😅”

After the initial Front-End Checklist and the Front-End Design Checklist, I wanted to continue creating more deep and complete Front-End checklists.

For years, I’ve been passionate about performance, so I naturally choose to focus this time, on a Front-End Performance Checklist. And this is not an easy topic, that’s probably why I’ll continue in the next days to work on it and which hopefully result in a complete checklist for Front-End developers (and for my team at Influitive Engineering).

(the original checklist can be found on Github)

Table of Contents

  1. HTML
  2. CSS
  3. Fonts
  4. Images
  5. JavaScript
  6. Server (in progress)
  7. JS Frameworks (in progress)

Introduction

Performance is a huge subject, but it’s not always a “back-end” or an “admin” subject: it’s a Front-End responsibility too. The Front-End Performance Checklist is an exhausted list of elements you should check or at least be aware of, as a Front-End developer and apply to your projects (personal and professional).

How to use?

For each rule, you will have a paragraph explaining why this rule is importante 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.

(You’ll find on the original Front-End Performance Checklist, 3 indicators of priority / impact that will help you to order theses rules.)

Performance tools

List of the tools you can use to test or monitor your website or application:

🛠 WebPagetest — Website Performance and Optimization Test
🛠 ☆ Dareboost: Website Speed Test and Website Analysis
🛠 GTmetrix | Website Speed and Performance Optimization
🛠 PageSpeed Insights
📖 Pagespeed — The tool and optimization guide
📖 Make the Web Faster | Google Developers
📖 Sitespeed.io — Welcome to the wonderful world of Web Performance

References

📖 The Cost Of JavaScript — YouTube
📖 Get Started With Analyzing Runtime Performance | Google Developers
📖 State of the Web | 2018_01_01
📖 Page Weight Doesn’t Matter

HTML

Minified HTML:

The HTML code is minified, comments, white spaces and new lines are removed from production files.

Why:

  • Removing all unnecessary spaces, comments and break 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.

🛠 HTML minifier | Minify Code
📖 Experimenting with HTML minifier — Perfection Kills

Remove unnecessary comments:

Ensure that comments are removed from your pages.

Why:

  • Comments are not really useful for the user then should be removed from production files. One case where you want to keep comments could be if you need to keep the origin for a library.

How:

  • ⁃ Most of the time, comments can be removed using an HTML minify plugin.

🛠 remove-html-comments — npm

Remove unnecessary attributes:

Type attributes like type="text/javascript"' ortype="text/css anymore and should be removed.

<!-- Before HTML5 -->
<script type="text/javascript">
// Javascript code
</script>
<!-- Today -->
<script>
// Javascript code
</script>

Why:

  • Type attributes are not necessary as HTML5 implies text/css and text/javascript as defaults. Unused code should be removed when not used by your website or app as they add more weight to your pages.

How:

  • ⁃ Ensure that all your <link> and <script> tags don't have any type attribute.

📖 The Script Tag | CSS-Tricks

Place CSS tags always before JavaScript tags:

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>.

📖 Ordering your styles and scripts for pagespeed

Minimize the number of iframes:

  • Use iframes only if you don’t have any other technical possibility. Try to avoid as much as you can iframes.

CSS

Minification:

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 are send to the client. It’s important to always minified 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.

🛠 cssnano: A modular minifier based on the PostCSS ecosystem. — cssnano🛠 @neutrinojs/style-minify — npm

Concatenation:

CSS files are concatenated in a single file (Not always valid for HTTP/2).

<!-- Not recommended -->
<link rel="stylesheet" href="="fonts.css"></link>
<link rel="stylesheet" href="components.js"></link>

<!-- Recommended -->
<link src="combined.js"></link>

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.

📖 HTTP: Optimizing Application Delivery — High Performance Browser Networking (O’Reilly)
📖 Performance Best Practices in the HTTP/2 Era

Non-blocking:

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 preload can actually load the CSS files before the browser starts showing the content of the page.

How:

  • ⁃ You need to add the rel attribute with the preload value and add as="style" on the <link> element.

📖 loadCSS by filament group
📖 Example of preload CSS using loadCSS
📖 Preloading content with rel=”preload”
📖 Preload: What Is It Good For? — Smashing Magazine

Length of CSS classes:

The length of your classes can have an (slight) impact on your HTML and CSS files (eventually).

Why:

  • Even performance impacts can be disputable, taking a decision on a naming strategy regarding your project can have a substantial impact on the maintainability of your stylesheets. If you are using BEM, in some cases, you can ended up with classes having more characters than need. It’s always important to choose wisely your names and namespaces.

How:

  • ⁃ Setting a limit in terms of number of characters could be interesting for some people, but ensuring that you broke down your website in components can help to reduce the amount of classes (and declarations) and the length of your classes.

🛠 long vs short class · jsPerf

Unused CSS:

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.

🛠 UnCSS Online
🛠 PurifyCSS
🛠 PurgeCSS
🛠 Chrome DevTools Coverage

CSS Critical:

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.

📖 Understanding Critical CSS
🛠 Critical by Addy Osmani on GitHub automates this.
📖 Inlining critical CSS for better web performance | Go Make Things
📖 Critical Path CSS Generator — Prioritize above the fold content :: SiteLocity

Embedded or inline CSS:

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 help you have a more maintainable code and keep your site accessible. But regarding performance, it’s simply because it decrease 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)

📖 Observe CSS Best Practices: Avoid CSS Inline Styles

Analyse stylesheets complexity:

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 above can also help you analysing and correct your code.

🛠 TestMyCSS | Optimize and Check CSS Performance
📖 CSS Stats
🛠 macbre/analyze-css: CSS selectors complexity and performance analyzer

Fonts

Webfont formats:

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.

📖 WOFF 2.0 — Learn more about the next generation Web Font Format and convert TTF to WOFF2
🛠 Create Your Own @font-face Kits » Font Squirrel
📖 Using @font-face | CSS-Tricks
📖 Can I use… WOFF2

Use preconnect to load your fonts faster:

<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

Why:

  • When you arrived on a website, your device needs to find out where you site live 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 ressource (fonts, CSS files…). Prefetches and preconnects allow the browser

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.

📖 Faster Google Fonts with Preconnect — CDN Planet
📖 Make Your Site Faster with Preconnect Hints | Viget
📖 Ultimate Guide to Browser Hints: Preload, Prefetch, and Preconnect — MachMetrics Speed Blog

Webfont size:

Webfont sizes don’t exceed 300kb (all variants included)

Images

Images optimization:

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.

📖 Image Optimization | Web Fundamentals | Google Developers
🛠 TinyJPG — Compress JPEG images intelligently

Images format:

Choose your image format appropriately.

Why:

  • To ensure that your images don’t slow your website, choose the format that will

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’s not.

📖 Serve Images in Next-Gen Formats | Tools for Web Developers | Google Developers
📖 What Is the Right Image Format for Your Website? — SitePoint
📖 PNG8 — The Clear Winner — SitePoint
📖 8-bit vs 16-bit — What Color Depth You Should Use And Why It Matters — DIY Photography

Use vector image vs raster/bitmap:

Prefer using vector image rather than bitmap images (when possible).

Why:

  • Vector images (SVG) tend to be smaller than images and SVG’s are responsive and scale perfectly. These images can be animated and modified by CSS.

Images dimensions:

Set width and height attributes on <img> if the final rendered image size is known.

Why:

  • If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).

Avoid using Base64 images:

You could eventually convert tiny images to base64 but it’s actually not the best practice.

📖 Base64 Encoding & Performance, Part 1 and 2 by Harry Roberts
📖 A closer look at Base64 image performance — The Page Not Found Blog
📖 When to base64 encode images (and when not to) | David Calhoun
📖 Base64 encoding images for faster pages | Performance and seo factors

Lazy loading:

Images are lazyloaded (A noscript fallback is always provided).

Why:

  • It will improve the response time of the current page and then avoid loading unnecessary images that the user may not need.

How:

  • ⁃ Use Lighthouse to identify how many images are offscreen.
    ⁃ Use a JavaScript plugin like to lazyload your images.

🛠 verlok/lazyload: Github
📖 Lazy Loading Images and Video | Web Fundamentals | Google Developers📖 5 Brilliant Ways to Lazy Load Images For Faster Page Loads — Dynamic Drive Blog

Responsive images:

Ensure to serve images that are close to your display size.

Why:

  • Small devices don’t need images bigger than their viewport. It’s recommended to have multiple versions of one image on different sizes.

How:

  • ⁃ Create different image sizes for the devices you want to target.
    ⁃ Use srcset and picture to deliver multiple variants of each image.

📖 Responsive images — Learn web development | MDN

JavaScript

JS Minification:

All JavaScript files are minified, comments, white spaces and new lines are removed from production files (still valid if using HTTP/2).

Why:

  • Removing all unnecessary spaces, comments and break will reduce the size of your JavaScript files and speed up your site’s page load times and obviously lighten the download for your user.

How:

  • ⁃ Use the tools suggested below to minify your files automatically before or during your build or your deployment.

📖 uglify-js — npm
📖 Short read: How is HTTP/2 different? Should we still minify and concatenate?

No JavaScript inside:

(Only valid for website) Avoid having multiple JavaScript codes embed in the middle of your body. Regroupe your JavaScript code inside external files or eventually in the <head> or at the end of your page (before </body>).

Why:

  • Placing JavaScript embedded code directly in your <body> can slow down your page because it loads while the DOM is being built. The best option is to use external files with async or defer to avoid blocking the DOM. Another option is to place some scripts inside your <head>. Most of the time analytics code or small script that need to load before the DOM gets to main processing.

How:

  • ⁃ Ensure that all your files are loaded using async or defer and decide wisely the code that you will need to inject in your <head>.

📖 11 Tips to Optimize JavaScript and Improve Website Loading Speeds

Non-blocking JavaScript:

JavaScript files are loaded asynchronously using async or deferred using defer attribute.

<!-- Defer Attribute -->
<script defer src="foo.js">
<!-- Async Attribute -->
<script async src="foo.js">

Why:

  • JavaScript blocks the normal parsing of the HTML document, so when the parser reaches a <script> tag (particularly is inside the <head>), it stops to fech and run it. Adding async or defer are highly recommended if your scripts are placed in the top of your page but less valuable if just before your </body> tag. But it's a good practice to always use these attributes to avoid any performance issue.

How:

  • ⁃ Add async (if the script don't rely on other scripts) or defer (if the script relies upon or relied upon by an async script) as an attribute to your script tag.
    ⁃ If your have small scripts, maybe use inline script place above async scripts.

📖 Remove Render-Blocking JavaScript

Optimized and updated JS libraries:

All JavaScript libraries used in your project are necessary (prefer Vanilla Javascript for simple functionalities), updated to their latest version and don’t overwhelm your JavaScript with unnecessary methods.

Why:

  • Most of the time, new versions come with optimization and security fix. You should use the most optimized code to speed up your project and ensure that you’ll not slow down your website or app without outdated plugin.

How:

  • ⁃ If your project use NPM packages, npm-check is a pretty interesting library to upgrade / update your librairies.

📖 You may not need jQuery
📖 Vanilla JavaScript for building powerful web applications

Check dependencies size limit:

Ensure to use wisely external librairies, most of the time, you can use a lighter library for a same functionnality.

Why:

  • You may be tempted to use one of the 745 000 packages you can find on npm, but you need to choose the best package for your needs. For example, MomentJS is an awesome library but with a lot of methods you may never use, that’s why Day.js was created. It’s just 2kB vs 16.4kB gz for Moment.

How:

  • ⁃ Always compare and choose the best and lighter library for your needs. You can also use tools like npm trends to compare NPM package downloads counts or Bundlephobia to know the size of your dependencies.

🛠 ai/size-limit: Prevent JS libraries bloat. If you accidentally add a massive dependency, Size Limit will throw an error.
📖 webpack-bundle-analyzer — npm
📖 Size Limit: Make the Web lighter — Martian Chronicles, Evil Martians’ team blog

JavaScript Profiling:

  • Check for performance problems in your JavaScript files (and CSS too).

Why:

  • JavaScript complexity can slow down runtime performance. Identifing these possible issues are essential to offer the smoothest user experience.

How:

  • ⁃ Use the Timeline tool in the Chrome Developer Tool to evaluate scripts events and found the one that may take too much time.

📖 Speed Up JavaScript Execution | Tools for Web Developers | Google Developers
📖 JavaScript Profiling With The Chrome Developer Tools — Smashing Magazine
📖 How to Record Heap Snapshots | Tools for Web Developers | Google Developers
📖 Chapter 22 — Profiling the Frontend — Blackfire

Server

Webpage size < 1500 KB:

Reduce the size of your page + resources as much as you can.

Why:

  • Ideally you should try to target < 500 KB but the state of web shows that the median of Kilobytes is around 1500 KB (even on mobile). Depending your target users, connexion, devices, it’s important to reduce as much as possible your total Kilobytes to have the best user experience possible.

How:

  • ⁃ All the rules inside the Front-End Performance Checklist will help you to reduce as much as possible your resources and your code.

📖 Page Weight
🛠 What Does My Site Cost?

Page load times < 3 seconds:

Reduce as much as possible your page load times to quickly deliver your content to your users.

Why:

  • Faster your website or app is, less you have probability of bounce increases, in other terms you have less chances to lose your user or future client. Enough researches on the subject prove that point.

How:

  • ⁃ Use online tools like Page Speed Insight or WebPageTest to analyze what could be slowing you down and use the Front-End Performance Checklist to improve your load times.

🛠 Compare your mobile site speed
🛠 Test Your Mobile Website Speed and Performance — Think With Google
📖 Average Page Load Times for 2018 — How does yours compare? — MachMetrics Speed Blog

Time To First Byte < 1.3 seconds:

Reduce as much as you can the time your browser waits before receiving data.

📖 What is Waiting (TTFB) in DevTools, and what to do about it
📖 Monitoring your servers with free tools is easy

Cookie size:

If you are using cookies be sure each cookie doesn’t exceed 4096 bytes and your domain name doesn’t have more than 20 cookies.

Why:

  • cookies is exchanged in the HTTP headers between web servers and browsers. It’s important to keep the size of cookies as low as possible to minimize the impact on the user’s response time.

How:

  • ⁃ Eliminate unnecessary cookies

📖 Cookie specification: RFC 6265
📖 Cookies
🛠 Browser Cookie Limits
📖 Website Performance: Cookies Don’t Taste So Good — Monitis Blog
📖 Google’s Web Performance Best Practices #3: Minimize Request Overhead — GlobalDots Blog

Minimizing HTTP requests:

Always ensure that every file requested are essential for you website or application.

Use a CDN to deliver your assets:

Use a CDN to deliver faster your content over the world.

📖 10 Tips to Optimize CDN Performance — CDN Planet
📖 HTTP Caching | Web Fundamentals | Google Developers

Serve files from the same protocol:

Avoid having your website using HTTPS and serve files coming from source using HTTP.

Serve reachable files:

Avoid requesting unreachable files (404).

Set HTTP cache headers properly:

Set HTTP headers to avoid expensive number of roundtrips between your browser and the server.

GZIP compression is enable:

Author

Build with ❤️ by David Dias at @influitive 🇨🇦

License

MIT

All icons are provided by Icons8

Thank you for reading!

That’s it. In case you like my new open-source project and find it useful, here are some things you can do to show your support:

  • Hit the clap 👏 button on this article a few times (don’t be afraid, you’ll not break anything)!
Hit the clap 👏 button!

✉️ Subscribe to CodeBurst’s once-weekly Email Blast, 🐦 Follow CodeBurst on Twitter, view 🗺️ The 2018 Web Developer Roadmap, and 🕸️ Learn Full Stack Web Development.

--

--

Software Engineer with a passion for Front-End & UX / UI • Life hacker who ♥ coding, meditation and solving digital and human problems