The challenge was to optimize this online portfolio for speed! In particular, to optimize the critical rendering path and make this page render as quickly as possible by applying the techniques I picked up in the Critical Rendering Path course.
- Added async attribute to all the JS files
- Added media="print" for the CSS.
- Inlined the style.css file
- Inlined the both the other JS scripts
- Moved the font link below the footer
- Compressed the profile pic and the pizzeria pic
Pagespeed Insights Scores
- index.html - Mobile(90),Desktop(90)
- project-2048.html - Mobile(95),Desktop(97)
- project-mobile.html - Mobile(95),Desktop(97)
- project-webperf.html - Mobile(96),Desktop(97)
Main.js changes
- In the function changePizzaSizes, a) Brought the declaration of dx,newwidth and randomPizzaContainer outside the loop b) Instead of using querySelectorAll, I am using getElementById now.
- In the function updatePositions, a) Brought the declaration of items,scrollTop and scrollTopNew outside the loop b) Instead of using querySelectorAll, I am using getElementsByClassName now.
- Decreased the number of iterations for the loop generating sliding pizza from 200 to 100.
HTML changes
- Inlined the style.css for pizza.html
Time to resize pizza
Time to generate last 10 frames