This Front-End Web Developer Nanodegree project showcases website performance optimization techniques. In human language, we make pages load faster and elements animate smoother.
The original source code is in folder src, the optimized code is in dist folder.
- PageSpeed score > 90 for index.html, both for Mobile and Desktop.
- Resizing pizzas in pizza.html takes < 5ms.
- pizza.html consistently renders at 60FPS or above.
Gulp, a popular task runner, is used to automate HTML/CSS/JS minifications and image optimization.
- Clone or download this repository.
- Install Node, a JavaScript runtime.
- Install npm, a Node package manager.
- Install Gulp.
- Go to cloned/downloaded directory
- Run 'npm install' to install packages this project depends on.
- Run 'gulp'
Code and other assets in dist will be re-generated from src folder again!
- HTML/CSS/JS are minified.
- Images are optimized.
- Inline render-blocking CSS.
- Move inline script from top of page to bottom of page.
- Load Google Analytics script asynchronously.
- Access DOM elements of moving pizzas once, not every time updatePositions is called.
- Reduce # of DOM elements by calculating # of moving pizzas from window size.
- Store upper bound of for loops in variable instead of calculating every time.
- Move variable declarations out of for loop.
- Replace querySelector/querySelectorAll with getElementById/getElementsByClassName.