GithubHelp home page GithubHelp logo

valerii-zinchenko / 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.9 MB

FEND Project 4. Optimizations

Home Page: http://valerii-zinchenko.github.io/frontend-nanodegree-mobile-portfolio/dest/index.html

CSS 2.21% HTML 56.63% JavaScript 41.16%

frontend-nanodegree-mobile-portfolio's Introduction

Website Performance Optimization portfolio project

Live links

Part 1: Optimize PageSpeed Insights score for index.html

The following techniques were applied to reduce the CRP and improve the site loading:

  • Minify CSS and JS files
  • Use "print" media query for print.css
  • Inline critical and small CSS and JS files into HTML file
  • Run all JavaScripts at the end of document's body
  • Download fonts and GA stuff asynchronusly from JavaScript at the end of the body after all critical JavaScript routines
  • Optimize images for different screen sizes and media qieries (nice example: pizza.html)

For today (21.06.2016) PageSpeed Insights displays:

  • 95 / 100 for mobile
  • 97 / 100 for desktop

Part 2: Optimize Frames per Second in pizza.html

Issue #1: Frame rate by scrolling the page

The problem was in updatePositions function that in the big loop was that the document.body.scrollTop was accessed every loop iteraction. So I have moved out all the code that can be done once and have leaved only that code that updates the element's styles. For comparision relative to my laptop, before the fix the average was about 150ms, after - 2-4ms.

Issue #2: Computational efficiency

The problem was that by changing the size of the pizza the content update took a lot of time. So problem function was resizePizzas. The following issues I found and fixed there:

  • unnecessary access ot the element's styles in loops
  • lot of code duplication
  • unnecessary creation of function inside of this function
  • the amount of computations with modulus operator was reduced (modulus operator is used by accessing the precalculated value only)
  • by resizing the control of the pizza size is moved to CSS, in JavaSCript file only proper class is selected and set to the main container

Before the fix, it was about 150ms by scrolling and 300ms for resizing on mt laptop, after - <1ms for both.

Great improvements, I would say. Now pizza.html is much more smother than before :)

Build and run

Build all from src

To build dest from the src folder you should run

$ npm install
$ grunt

It will autimatically:

  • minify CSS and JS files
  • process imroved HTML files (with _improved suffix), i.e. inline resources
  • generate images with different sizes

Run

Simple hand-written node.js server is available. To run the site from localhost just type

node web-server.js

and you will see in the command line where it is started

Run with ngrok

Install ngrok

npm install ngrok -g

Start local server (described above) and start ngrok

ngrok http 8080

where 8080 is port of your local server

frontend-nanodegree-mobile-portfolio's People

Contributors

aaronbutler avatar cameronwp avatar durant-udacity avatar hkasemir avatar mrk-nguyen avatar nicolasartman avatar safadurimo avatar susansmith avatar valerii-zinchenko avatar walesmd avatar

Watchers

 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.