joryphillips / joryphillips.github.io

Jory's portfolio/resume website
https://joryphillips.com
ISC License
2 stars 0 forks source link

Portfolio/Resume Website Implementation - a 2020 retrospective #8

Closed joryphillips closed 3 years ago

joryphillips commented 4 years ago

Portfolio/Resume Implementation - a 2020 retrospective

The current portfolio/resume website implementation has some advantages but also has some problems.

First, the positives:

The negatives:

Some ideas:

joryphillips commented 4 years ago

As expected, getting rid of the Promise.all() for all project images and instead using an intersection observer dramatically cut down on the page load time.

With a window size that fits eight images, the visible part of the page was fully loaded in just under 850ms. Screen Shot 2020-04-08 at 11 27 15 PM

It is probably good to note that the images themselves are in no way optimized for the size that they are displayed, so more gains could still be made in that regard.

joryphillips commented 4 years ago

Perf Analysis of Various Improvements

Moving the font import, along with bundling, minifying, and code splitting the JS had even more fantastic results.

I established a baseline test scenario by using Chrome DevTool's Fast 3G network throttle, and sized the viewport to only show 3 images in the page's 'Visuals' section. The cache is disabled for all tests.

Initial Code

Requested content painted at 18s The page loads but perf profiling stops before any projects or images are shown. With the network throttle, that finally happens nearly 18 seconds after the page is requested. The culprit is the author's foolish desire to have images all nicely fade in at once, which requires loading them all first with Promise.all(). Anyone working in a production environment would consider this broken and the implementation an anti-pattern for slow network bandwidth content delivery. Clearly this needed to be fixed (and was!).

Screen Shot 2020-04-09 at 2 25 13 PM

Adding Intersection Observer

Requested content painted at 4.7s Only three images are loaded, which is all we need, but that doesn't happen until nearly 3 seconds have passed. Still, this change alone is a massive improvement for slow networks.

Screen Shot 2020-04-09 at 2 17 29 PM

Bundle All JS

Requested content painted at 3.8s Converting static JSON data to TS and bundling it with all compiled JS into one big file results in the images starting to load about 1 full second sooner. This is a pretty big deal. Strangely, files don't start to load until after the CSS for the Google font is loaded.

Screen Shot 2020-04-09 at 2 12 12 PM

Move font import to HTML, minify and code split JS

Requested content painted at 3.2s Finally, moving the Google font import to the HTML file drops the time to start loading images by just under a half second. Minifying the JS, and code splitting so that we aren't loading things we don't need yet, helps achieve this and drops JS load time by about 200ms.

Screen Shot 2020-04-09 at 2 09 36 PM

Summary

After fixing the initial Promise.all() image load problem and using an Intersection Observer, we are able to decrease page load time by ~30% (1.5 seconds) on a throttled Fast 3G connection using bundling, minifying, code splitting, and being mindful about when and where fonts are imported.