Code Monkey home page Code Monkey logo

project-2-1819's Introduction

Optimizing volkswagen.nl

Summary

This readme contains my research on Volkswagen's website and advice on how to improve the accesibility and performance of the website. Overview

Installation

Fork and/or clone it

git clone https://github.com/Arash217/project-2-1819

Install dependencies

npm install

Run the server (will use port 3000)

npm start

Optimizations

1. Adding Brotli compression

Most of the assets of the website are compressed with Gzip. To reduce the size even further, Brotli compression can be used. I took the HTML, CSS and JavaScript files of the website, added Brotli compression and compared them with the Gzipped version of the website.

Results

Note: I only took three files, to show the difference between Gzip and Brotli compression. The website still has other files that can be compressed with Brotli.

2. Minifying and compressing SVG files

The SVG files of the website aren't minified or compressed. Minifying them and adding Gzip and/or Brotli compression can be used to further reduce the sizes of the SVG files.

Results

Note: I only took the SVG files on the homepage to minify and compress. I didn't test the SVG files on the other pages.

3. WebP images

The images on the website are mostly jpg, with the exception of some png, gif and svg. Converting these images to WebP can reduce the size significantly.

Results

Note: I only took the JPG and PNG images on the homepage to convert to WebP. I didn't test the images on the other pages.

4. FOIT

The website uses a custom font which is applied when it's loaded. However, because of this loading, the text will be invisible until the custom font is loaded, causing Flash of Invisible Text (FOIT).

Original

Fix

This issue can be solved by adding 'font-display: swap;' to all '@font-face' rules.

@font-face {
    font-family: VWHeadWeb;
    src: url(../../../Fonts/VW-PKW/VWHeadWeb-Light.woff2) format("woff2"), 
         url(../../../Fonts/VW-PKW/VWHeadWeb-Light.woff) format("woff");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
...

This, however caused the anchor tags to be unstyled until the CSS file was loaded. I solved this issue by adding a style sheet directly in the html:

<style>
a {
  color: #41494c;
}
</style>

It also could have been in a separate CSS file, but I didn't test this.

Result

Note: the dropdown menu (Meer) in the navigation is shown when the JavaScript file is loaded. This issue can for example be solved by adding the JavaScript responsible for the menu directly in the HTML file as a script tag.

Reflow

While 'font-display: swap;' works, it might cause reflow, since the fallback font family and the custom font family have different font sizes. This issue can be solved by making sure that the font sizes match. Font style matcher for example, can be used for this.

5. Service Worker

Initially, my idea was to cache third party scripts in the website with a service worker, but it didn't work out because the scripts have dynamic urls. However, a service worker can still be used to cache the files that are cached by the browser itself (HTTP cache). Using a service worker along browser/HTTP cache will give you more control over the cache, since you can use the power of a programming language.

Results

Browser/HTTP cache

Service worker

Note: I used as a proof of concept, the tool sw-precache to generate a service worker which caches the assets of the website. The config file (sw-precache-config.js) for the service worker can be found in the root directory of the project. However, this tool is deprecated and shouldn't be used in production. Use Workbox instead if you want/need to use tooling to generate service workers for production.

Sources

Licence

MIT © Arash Paknezad

project-2-1819's People

Contributors

arash217 avatar joostf avatar koopreynders avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.