Tag: Html5

Hugo Picture Shortcode With Multiple Sources

A Hugo shortcode using the HTML picture element to enable different formats for the same image

4 minute read

A while ago I published this post about a better figure shortcode for Hugo that enabled lazy loading. Today, I bring you yet another update on the same shortcode. This time around, the focus is on leveraging the HTML picture element, which enables alternative versions of the same image in different formats, leaving the browser to decide which one to use. You can serve the same image in, for instance, JPEG-XL and plain old JPEG at the same time. The browser will read the tag, and select the appropriate image depending on its capabilities. If you use a JPEG-XL-capable browser (Thorium, Pale Moon, Basilisk, Waterfox, LibreWolf, Firefox Nightly), you will be served the smaller JPEG-XL version, otherwise you will get the plain JPEG version.

HTML Lazy Image Loading

Adding lazy image loading to Hugo's figure shortcode

3 minute read

The HTML <img /> tag has this handy attribute loading="lazy" that enables lazy image loading, so that images are only loaded whenever the user scrolls all the way down to their position. This makes page loading super-fast, and reduces the amount of wasted bandwidth, especially when browsing from page to page. In the past this was achieved by a few lines of custom JavaScript code, but it is supported by all major browsers, both for PC and mobile. It should always be used unless there’s a very good reason not to, to the point where it can probably be argued that it should be the default behavior of images.

1 minute read

HTML5 Snake Game

HTML5 Snake Game

Lately, I have been messing around with a snake game written in HTML5+js. A great deal of parameters can be modified in real time using an input form in the same page, such as the width and length of canvas, cell shape, background colour, food colour, snake colour and the speed of the game. Also, I posted the full javascript code.

If you are interested, you can check the results here.

Website design by myself. See the privacy policy.
Content licensed under CC-BY-NC-SA 4.0 .