Closed joryphillips closed 3 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.
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.
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.
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!).
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.
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.
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.
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.
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:
col col-6 sm-col-6 md-col-4 lg-col-3 px1 lg-px2 lg-p1 mb4
, I think looking at line-by-line CSS rules that provide a grid, padding, and margins for that DOM element would be faster to understand and edit, as opposed to this long horizontal string of shorthand.Some ideas:
loading="lazy"
for images instead of the currentPromise.all() then show
method.