RFPN
Rambling First Person Narrative

It’s what Monday evenings are for

Is now the best time to discover that my own CMS on my own website won’t let me add content? Ah well - at least it gets me off web-based / browser-based stuff and onto good old Notes.

I’m not too furious with myself for the glitch though. These things happen when you’re a maverick webdev prepared to risk the occasional breakage in the name of progress - and the Internet without progress is GeoCities and MySpace and nobody wants that.

I’ve been contemplating some contract work to help pay this winter’s utilities bills. I’ve not looked for work since, well ever really, relying instead on Karma and bumping into someone in a pub that needs a website that will go from £0 to £1M in a year with no advertising budget. But Karma, luck or whatever you call it, isn’t passive. You need to generate it, or at least give it something to work with - sow some seeds and all that.

Several times over the years I’ve been asked if I can deliver a project who’s key unique element just happens to have been a thing I’ve just been playing with - not because it was part of any other project, but because it was a interesting and/or a challenge.

If that sounds like a justification for avoiding old mundane work in favour of new sparkly stuff, well shush - I have faith. A few more days of fiddling with interesting stuff and then all I’ll need to do is find the right pub - or at least a different one from the one I’m in wile writing this.

I feel the need to recap on things that I’ve been tinkering with over the past few days (while some people have been in Gibraltar). Top new discovery of the week is the multiple image source tag thing.

Dull, mildly technical bit alert

So… the pages that my systems produce are, as they should be, ‘mobile friendly’, i.e. their layout changes depending on the space they’re in. [link to demo - who has time for that?]. If you’ve on a desktop machine you can see that as you change the size of the browser window, the layout changes - columns narrow and or collapse. No biggie, until you run your stuff though Lighthouse and it tells you that the images you’re sending are too big and you're a bad developer dinosaur destined for terrible SERPS.

I’ve always generated a set of different sizes for each image. It’s an obvious thing to do. If your page has a fullscreen background image - you need a big image. If you page has a list of things that each has a thumbnail image, they almost certainly need much smaller images. Stay with me - nearly there.

With responsive layouts, you don’t always know exactly what image size is needed.. You should know the different sizes that might be needed though, so say hello to my little friend 'srcset'. Who knew you could tag an image with lists? The first list is paths to images and their widths, and the second is a set of screen widths with corresponding 'best-match' sizes. (Just because the screen is bigger does not mean the image needs to be bigger - perhaps I should do that demo page...) With the two lists of image paths and media query rules, the browser can then choose to use whichever files it thinks is best.

The things I most like about this approach is that I can finally set my backend image widgets to generate a set of images that more closely match the set of display widths that the frontend needs, and the code that generate the front-end HTML can ask for set of images with the corresponding lists - thanks to my latest ‘view on demand’ thing. I say ‘thing’, mainly because I’m told that the way I use classes and objects is not normal, and I don’t want to confuse the really clever coders. Whatever you call it, my thing takes info - like a row of data, or an id of a database record - and gives back some handy stuff that the front end of a system can use. Until recently, thingy produced a growing set of view components - a list item view, a ‘card’ view, a table row, a json version, a set for public visitors, another for someone logged in, another set for a super user and one each for various nursery rhyme characters.

I’ve had a word with thingy. I’ve explained that it’s fine to carry on with his old ways, but if little bit of meta data is present that specifies the view and the user, then hey - just grab the relevant bits and take the rest of the day off. Oh how we laughed!