Terence Eden. He has a beard and is smiling.

Terence Eden’s Blog

Theme Switcher:

Reasonably accurate, privacy conscious, cookieless, visitor tracking for WordPress

· 6 comments · 1,100 words · Viewed ~712 times


The Logo for WordPress.

I am vain. I like to know which of my blog posts have "done numbers". I get a little thrill knowing that an old post I wrote has been read by someone in a land I've never visited. I'm curious and want to know if a newsletter has linked to me. At the same time, I don't want to know too much about people. I don't want to stalk them around the web. I refuse to care how long they spend with me. I…

What about using rel="share-url" to expose sharing intents?

· 13 comments · 450 words · Viewed ~7,956 times


Screenshot. "Share this page on" followed by colourful icons for popular social networks.

Let's say that you've visited a website and want to share it with your friends. At the bottom of the article is a list of popular sharing destinations - Facebook, BlueSky, LinkedIn, Telegram, Reddit, HackerNews etc. You click the relevant icon and get taken to the site with the sharing details pre-filled. The problem is, every different site has a different intent for sharing links and…

1KB JS Numbers Station

· 7 comments · 700 words · Viewed ~11,752 times


Random monochrome tiles with the word Numbers Station superimposed.

Code Golf is the art/science of creating wonderful little demos in an artificially constrained environment. This year the js1024 competition was looking for entries with the theme of "Creepy". I am not a serious bit-twiddler. I can't create JS shaders which produce intricate 3D worlds in a scrap of code. But I can use slightly obscure JavaScript APIs! There's something deliciously creepy about…

Decorative text within HTML

· 9 comments · 500 words · Viewed ~12,120 times


An ASCII art bunny hiding in the source code.

Back in 2020, Andy Bell introduced me to the idea of grouping attribute values. You've probably seen something like this before: <article class="card-section-background1-colorRed" ></article> A single class over-encumbered by all sorts of things. The more modular way to write this would be: <article class="card section box bg-base color-primary" ></article> That's pretty good! Each…

Stop using preg_* on HTML and start using \Dom\HTMLDocument instead

· 5 comments · 850 words · Viewed ~1,007 times


The PHP logo.

It is a truth universally acknowledged that a programmer in possession of some HTML will eventually try to parse it with a regular expression. This makes many people very angry and is widely regarded as a bad move. In the bad old days, it was somewhat understandable for a PHP coder to run a quick-and-dirty preg_replace() on a scrap of code. They probably could control the input and there wasn't …

HTML Oddities: Is a newline just another whitespace in attribute values?

· 600 words · Viewed ~480 times


The HTML5 Logo.

Consider these two HTML elements: <div class="a b">…</div> <div class="a b">…</div> Is there any semantic difference between them? Is there any way to target one but not the other? In other words, are they logically different? I think the answer is no. On every browser I've tested, both are the same. Whether using JS or CSS, there's no difference between them. You could replace every \n wit…

Using Tempest Highlight with WordPress

· 1 comment · 300 words · Viewed ~254 times


The HTML5 Logo.

I like to highlight bits of code on my blog. I was using GeSHi - but it has ceased to receive updates and the colours it uses aren't WCAG compliant. After skimming through a few options, I found Tempest Highlight. It has nearly everything I want in a code highlighter:  PHP with no 3rd party dependencies.  Lots of common languages.  Modern, with regular updates.  Easy to use fun…

HTML Oddities: Does the order of attribute values matter?

· 7 comments · 550 words · Viewed ~1,522 times


The HTML5 Logo.

HTML elements can have attributes. For example id, class, src, alt, and many others. These attributes can contain values - an img element's src attribute has a value which is a link to an image. An id attribute's value is a single string. But some attributes can contain multiple values. Here's a thought experiment for you. Consider these two HTML elements: <p class="alpha bravo charlie">………</p> …

A small PHP update to GeSHi

· 250 words · Viewed ~204 times


The PHP logo.

The faithful old GeSHi Syntax Highlighter hasn't seen an update in a many a long year. It's a tried and trusted way to do server-side code highlighting - turning a myriad of programming languages into beautiful HTML & CSS. A few weeks ago, I noticed someone had proposed an update to its HTML rendering. The changes were mostly adding in new element names. PHP has been updated several times…

Introducing Pretty Print HTML for PHP 8.4

· 550 words · Viewed ~537 times


The HTML5 Logo.

I'm delight to announce the first release of my opinionated HTML Pretty Printer for new versions of PHP. Grab the code from Packagist Contribute on GitLab There are several prettifiers on Packagist, but I think mine is the only one which works with the new Dom\HTMLDocument class. Table of ContentsWhatHowLimitationsWhyNext Steps What This takes hard-to-read HTML like: <!doctype…

Pretty Print HTML using PHP 8.4's new HTML DOM

· 1 comment · 950 words · Viewed ~755 times


The PHP logo.

Those whom the gods would send mad, they first teach recursion. PHP 8.4 introduces a new Dom\HTMLDocument class it is a modern HTML5 replacement for the ageing XHTML based DOMDocument. You can read more about how it works - the short version is that it reads and correctly sanitises HTML and turns it into a nested object. Hurrah! The one thing it doesn't do is pretty-printing. When you call…

How to prevent Payment Pointer fraud

· 9 comments · 1,000 words · Viewed ~714 times


Web Monetization The Web Monetization API allows websites to automatically and passively receive payments from Web Monetization-enabled visitors.

There's a new Web Standard in town! Meet WebMonetization - it aims to be a low effort way to help users passively pay website owners. The pitch is simple. A website owner places a single new line in their HTML's <head> - something like this: <link rel="monetization" href="https://wallet.example.com/edent" /> That address is a "Payment Pointer". As a user browses the web, their browser takes …