thenewboston-blockchain / Website

The website for thenewboston.
https://thenewboston.com
MIT License
597 stars 360 forks source link

Utilise CSS sprites for logos to prevent overhead to fetch multiple images #2187

Closed jamessspanggg closed 1 year ago

jamessspanggg commented 2 years ago

Background

Currently in pages such as https://thenewboston.com/social, the page issues a HTTP request for each of the logos, which might cause unnecessary overhead (there are more than 10 logos). We can instead use CSS sprites to reduce the number of HTTP requests to a single one.

Changes

Added dependency for spritesmith-cli to achieve this use case. Also reduced the size of some logos as they were unnecessarily big in size.

Running npm run css-sprite will generate the logos-sprite.png image, as well as the MarketingCard/sprite.scss file

Before

Screen Shot 2022-02-09 at 9 54 40 PM

After

Screen Shot 2022-02-09 at 9 54 51 PM

References: https://css-tricks.com/css-sprites/