Giter Site home page Giter Site logo

webperformance's Introduction

Website Performance Optimization portfolio project

This project goal is to optimize this online portfolio for speed. The steps that I have done shown below:

  • Part 1: Optimize the Critical Rendering path(CPR) by using PageSpeed tool to achieves a score of 90 above for Mobile and Desktop (index.html)
  • Part 2: Improve the frame-rate at 60fps when scrolling. (main.js) & (pizza.html).
  • Part 3: Resize the pizza images in less 5 ms by using the pizza size slider. To get started, check out the repository and inspect the code.

Getting started

Part 1: Optimize PageSpeed Insights score for index.html (For Windows)

Some useful tips to help you get started:

  1. Check out the repository
  2. To inspect the site on your phone, you can run a local server
$> cd /path/to/your-project-folder
$> python -m http.server 8080
  1. Open a browser and visit localhost:8080
  2. Download and install ngrok to the top-level of your project directory to make your local server accessible remotely.
$> cd /path/to/your-project-folder
$> ./ngrok http 8080

The index.html originally had a Google PageSpeed score of under 50/100 for mobile & desktop. After optimized the index.html the scored increased to above 90/100 for both mobile and desktop.

What has been changed?

  • Removed the Google Font
  • Added the async attribute to all scripts tags.
  • Moved all the scripts tags file to bottom.
  • Minified CSS using Gulp.js and inlined all of the CSS.
  • Added the media="print" attribute to avoid CSS Render Blocking.
  • Resized a image that were too large (Using Adobe PhotoShop).
  • Optimize images by compressed all images using Gulp.js.

Part 2: Optimize Frames per Second in pizza.html

To optimize views/pizza.html, you will need to modify views/js/main.js until your frames per second rate is 60 fps or higher. You will find instructive comments in main.js.

You might find the FPS Counter/HUD Display useful in Chrome developer tools described here: Chrome Dev Tools tips-and-tricks.

To reach a frame rate of 60fps for the pizza.html. I made the following changes in main.js:

  • Reduces the number of element pizzas created on the webpage from 200 to 36
  • Changed the 'querySelectorAll() to 'getElementsByClassName()' for quicker access to our DOM elements.
  • Created "topScroll" variable (var scrollTop = document.body.scrollTop / 1250;)
  • Moved the Math.sin calculation out of the 'for' loop
  • Used an array to stored 5 unique phases for each scroll to reduce the scripting time.
  • Used the transformX instead of items.style.left = = items[i].basicLeft + 100 * phase + 'px'; to reduce the layout time
  • Added some extra properties to the CSS for the .mover class. e.g. (will-change: transform; transform translate3d(0,0,0); and backface-visibility: hidden;)

Part 3: Optimize the computational effieciency

To make time to resize pizza elements less than 5ms. I made the following changes in main.js:

  • In function changePizzaSizes(), replaced "querySelectorAll()" to getElementsByClassName().
  • In the same function, i moved all the variable declarations outside the 'for' loop. e.g. (var dx,newidth, i)

Gulp Installation & Resources Used

Resources Used

Optimization Tips and Tricks

Customization with Bootstrap

The portfolio was built on Twitter's Bootstrap framework. All custom styles are in dist/css/portfolio.css in the portfolio repo.

webperformance's People

Contributors

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