Code Monkey home page Code Monkey logo

pizzeria_portfolio's Introduction

Website Performance Optimzation

Overview

As a part of Udacity's Front-end Web Developer Nanodegree I was challenged to optimize a website created by course developer Cameron Pittman that contained many performance-related issues.

Getting Started

Original

Cam's original live version can be found here This is a link to the GitHub repo

Optimized

My optimized version is linked here This is a link to my GitHub repo

Optimization

Index Page

The index page orginially had a Google Page Speed Insights score of 28/100 mobile and 30/100 desktop. After implementing the following optimizations I was able to achieve a score of 93/100 on mobile and 94/100 on desktop.

JavaScript

Minified the Javascript using this tool and added the async attribute to all script tags.

CSS

Minified the CSS using this tool and inlined it as well. Added the media = "print" attribute to the external print style sheet linked.

Images

Large images were compressed and re-sized using this site.

Font

Removed the link to Google Fonts and instead applied the font style directly in the CSS body, button, input, select, textarea { font-family: 'Open Sans', sans-serif; color: #333; }

Cam's Pizzeria

There were two major assignments for this page:

  1. Resize the pizzas in < 5ms
  2. Achieve a consistent frame rate at 60fps when scrolling
Resizing the pizzas

Initially the pizzas were resizing at 211.8ms (yikes!). After implementing the following code the pizzas are now resizing at 0.8ms. See lines 401-452

60fps

Initialls the average time to generate the last 10 frames was around 60ms, after optimizations this number decreased to about 0.6ms for 10 frames. By utilizing Chrome Dev Tools Timeline I was able to track the fps and reduce jank. Specifically changes in the updatePositions() function as well as adding a scroll event listener to call the rAF so the animations are requested when scrolling. This link was a great source. See lines 494-580 for detailed comments of changes.

Other Changes to main.js
  • querySelector and querySelectorAll were replaced with getElementById and getElementsByClassName which are much faster.
  • Several variables were decared and calculated outside of loops where possible to enhance performance.
  • Generate 50 pizzas on page load instead of 200 to increase speed
CSS changes

After reading these tips the following style attributes were added to the .movers element:

-webkit-transform: translateZ(0);
will-change: transform, opacity;```

pizzeria_portfolio's People

Contributors

megdollar avatar

Watchers

 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.