GithubHelp home page GithubHelp logo

jscott10 / frontend-nanodegree-mobile-portfolio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from udacity/frontend-nanodegree-mobile-portfolio

0.0 2.0 0.0 3.73 MB

CSS 2.15% HTML 43.09% JavaScript 54.76%

frontend-nanodegree-mobile-portfolio's Introduction

Website Performance Optimization portfolio project

The project can be viewed in a browser at this URL:

http://jscott10.github.io/frontend-nanodegree-mobile-portfolio/

Objective 1: Achieve 90+ score on PageSpeed Insights (mobile and desktop) on index.html:

Optimizations

Changes to index.html

  • Move the inline Google Analytics function to the bottom of the page
  • Add async attribute to the analytics.js link
  • Use inline javascript to reference the Google Font
  • Make the css from style.css inline
  • Specify "media='print'" for print.css link

Images

  • Store local copies of the external images
  • Resize the pizzeria.jpg image to 100px (per inline style)

Optmizations

  • Optimize images (grunt-contrib-imagemin)
  • Minify javascript (grunt-contrib-uglify)
  • Minify css (grunt-contrib-cssmin)
  • Minify html (grunt-contrib-htmlmin)

Pagespeed: 93 mobile / 95 Desktop

Objective 2: Achieve 60fms scrolling on pizza.html

Optimizations

updatePositions():

  • Refactor document.body.scrollTop out of the for loop (line 527) to eliminate forced synchronous layout.
  • Replace querySelectorAll(".mover") with getElementsByClassName("mover") (line 529), the latter executes faster.
  • Specify pizza image locations using transform instead of left (line 535). Left triggers layout and paint, transform only trigger composite.
  • translate3d(x,y,z) is faster than translateX(x) because translate3d(x,y,z) forces the composite operation onto the GPU (http://stackoverflow.com/questions/22111256/translate3d-vs-translate-performance)

addEventListener("scroll", updatePositions):

  • Added code to calculate initial positions (lines 574-576).
  • Added code to calculate the number of visible pizza rows (lines 562-565)

Page scrolls at 60fms.

Objective 3: Achieve <5ms pizza resizing on pizza.html

Optimizations

  • Eliminate determineDx(elem, size), factoring out sizeSwitcher(size). (line 457)
  • Change sizeSwitcher to return a percentage value
  • Refactor to move document.querySelectorAll(".randomPizzaContainer") out of the for loop. (line 474)
  • Replace querySelectorAll(".randomPizzaContainer") with getElementsByClassName("randomPizzaContainer") (line 474), the latter executes faster.
  • Set randomPizzaContainers[x].style.width to a percentage value.

Pizza resizing occurs in ~0.4ms

frontend-nanodegree-mobile-portfolio's People

Contributors

jscott10 avatar durant-udacity avatar mrk-nguyen avatar nicolasartman 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.