Challenge from Udacity to modify a simple website with the express purpose of making it performant. Specific requirements:
- Edit index.html to achieve a PageSpeed score of at least 90.
- Optimize pizza.html to render with a consistent frame-rate at 60fps when scrolling.
- Reduce resize pizza time to less than 5 ms.
For this project, I used Gulp to automate tasks such as html minification, javascript uglification, and css inlining. Image optimization was accomplished separately.
Project File Structure:
/project /source /builds /development /production
Source: original files
Development: working files
Production: optimized output
The default Gulp task is configured to optimize development files and store the result in the production folder. This task will also serve production files on a local server, if available.
To install:
- Clone repo.
- In terminal application, run npm install to install dependencies.
- Open index.html in the browser of your choice.
Pageinsights for index page:
- Execute javascript asynchronously where possible.
- Use media=print option for print.css stylesheet.
- Minified javascript, css, and html.
- Optimized images.
- Inlined css.
Scroll of pizza page:
- Refactored updatePositions and EventListener('DOMContentLoaded') code in main.js.
- In main.js, used requestAnimationFrame and throttling code to optimize browser response to scrolling events.
Pizza resize on pizza page:
- In main.js, refactored resizePizzas code to improve CRP performance.
- In main.js, used requestAnimationFrame to resize pizzas in batches.
Other:
- In main.js, altered randomPizzaGenerator to append a document fragment containing newly generated pizzas to the DOM.
- Replaced slider in pizza.html with radio button.
Having issues downloading this project? Please contact me at [email protected].
This project is unlicensed. It was developed using images and base code provided by Udacity.