Scout
@adactio i can’t resist those green 100 scores! i’m a sucker for positive feedback :D
Lighthouse says https://saltercane.com is š šÆšÆšÆšÆ š
@adactio i can’t resist those green 100 scores! i’m a sucker for positive feedback :D
With the release of a new Salter Cane album I figured it was high time to update the design of the bandās website.
Hereās the old version for reference. As you can see, thereās a connection there in some of the design language. Even so, I decided to start completely from scratch.
I opened up a text editor and started writing HTML by hand. Same for the CSS. No templates. No build tools. No pipeline. Nothing. It was a blast!
And lest you think that sounds like a wasteful way of working, I pretty much had the website done in half a day.
Partly thatās because you can do so much with so little in CSS these days. Custom properties for colours, spacing, and fluid typography (thanks to Utopia). Logical properties. View transitions. None of this takes much time at all.
Because I was using custom properties, it was a breeze to add a dark mode with prefers-color-scheme. I think I might like the dark version more than the default.
The final stylesheet is pretty short. I didnāt bother with any resets. Browsers are pretty consistent with their default styles nowadays. As long as youāve got some sensible settings on your body element, the cascade will take care of a lot.
Thereās one little CSS trick I think is pretty cleverā¦
The background image is this image. As you can see, itās a rectangle thatās wider than it is tall. But the web pages are rectangles that are taller than they are wide.
So how I should I position the background image? Centred? Anchored to the top? Anchored to the bottom?
If you open up the website in Chrome (or Safari Technical Preview), youāll see that the background image is anchored to the top. But if you scroll down youāll see that the background image is now anchored to the bottom. The background position has changed somehow.
This isnāt just on the home page. On any page, no matter how tall it is, the background image is anchored to the top when the top of the document is in the viewport, and itās anchored to the bottom when you reach the bottom of the document.
In the past, this kind of thing mightāve been possible with some clever JavaScript that measured the height of the document and updated the background position every time a scroll event is triggered.
But I didnāt need any JavaScript. This is a scroll-driven animation made with just a few lines of CSS.
@keyframes parallax { from { background-position: top center; } to { background-position: bottom center; }
}
@media (prefers-reduced-motion: no-preference) { html { animation: parallax auto ease; animation-timeline: scroll(); } }
}
This works as a nice bit of progressive enhancement: by default the background image stays anchored to the top of the viewport, which is fine.
Once the site was ready, I spent a bit more time sweating some details, like the responsive images on the home page.
But the biggest performance challenge wasnāt something I had direct control over. Thereās a Spotify embed on the home page. Aināt no party like a third party.
I could put loading="lazy" on the iframe but in this case, itās pretty close to the top of document so itās still going to start loading at the same time as some of my first-party assets.
I decided to try a little JavaScript library called ālazysizesā. Normally this would ring alarm bells for me: solving a problem with third-party code by adding ā¦more third-party code. But in this case, it really did the trick. The library is loading asynchronously (so it doesnāt interfere with the more important assets) and only then does it start populating the iframe.
This made a huge difference. The core web vitals went from being abysmal to being perfect.
Iām pretty pleased with how the new website turned out.
22 Likes
# Liked by Royce Williams on Friday, January 31st, 2025 at 9:26am
# Liked by Jack Barber on Friday, January 31st, 2025 at 9:38am
# Liked by dominik schwind on Friday, January 31st, 2025 at 9:51am
# Liked by Jaz ⢠Design ⢠Hocus Focus on Friday, January 31st, 2025 at 10:06am
# Liked by ŠŠ»ŠµŠŗŃа šŗš¦ on Friday, January 31st, 2025 at 10:06am
# Liked by Mark Howells-Mead on Friday, January 31st, 2025 at 10:06am
# Liked by Web Fundi on Friday, January 31st, 2025 at 10:39am
# Liked by xypnox on Friday, January 31st, 2025 at 10:47am
# Liked by Stuart on Friday, January 31st, 2025 at 11:06am
# Liked by Tom dB on Friday, January 31st, 2025 at 11:06am
# Liked by Anders Thoresson on Friday, January 31st, 2025 at 11:21am
# Liked by Scout on Friday, January 31st, 2025 at 11:21am
# Liked by Noel Jackson on Friday, January 31st, 2025 at 11:32am
# Liked by Jackson Wilkinson on Friday, January 31st, 2025 at 11:59am
# Liked by Jordi SƔnchez on Friday, January 31st, 2025 at 1:49pm
# Liked by Robert Carr on Friday, January 31st, 2025 at 2:16pm
# Liked by Zach Leatherman on Friday, January 31st, 2025 at 2:16pm
# Liked by Eat This Podcast on Friday, January 31st, 2025 at 2:19pm
# Liked by A List Apart āfor people who make websitesā 1997ā? on Friday, January 31st, 2025 at 4:04pm
# Liked by Zachary Jewell on Friday, January 31st, 2025 at 4:12pm
# Liked by Rich Holman on Friday, January 31st, 2025 at 5:46pm
# Liked by Dylan K. on Friday, January 31st, 2025 at 8:28pm