sknob/music v5.4.0 Release Notes, Fetch Edition!
In the first post in this series, I explained why I used PHP to generate the playlist of my new hand-crafted music site from a large-ish XML file, instead of doing it locally like I used to (damn you Chrome and Firefox for dropping XSLT support!)
Thing is, depending on the speed of your device and your internet connection, it takes a few short seconds for PHP to do it’s thing on the server, before sending the result in one go to your browser.
And this slight delay has been nagging at me since day one.
So I’ve been thinking of ways to load the very lightweight page skeleton, and then retrieve the rendered playlist from the server.
And I finally took the time to figure out how to do it, using the javascript Fetch API to fetch the PHP code in a separate file once the skeleton loads. Which meant rethinking a bit of code for everything to keep working like before (basically making sure the data is loaded before calling anything critical).
After ironing out the kinks, I’m pretty sure I have a version that works!
The question now is, do I actually like it better? It does have the following advantages:
- The site loads instantly, even on a slow device.
- There’s a fun little loading animation. I went with an austere design after years of visual excess, so the animation reintroduces a touch of whimsy.
- When you click on a link to an album or a song from somewhere else like here (or your Mastodon feed), you get a bit of visual context before the page scrolls down to the target album or song.
I did a quick poll on Mastodon, which came out in favor of NOT going this route. Still, if you’re reading this, it probably means I decided to roll it out anyway.
It’ll be easy enough to roll back if I change my mind or if it proves to be troublesome or unpopular.