Dublin Library

The Publishing project

Building a performance test suite

Ever so often you see questions in Quora about Bravehttps://brave.com/, a Chromium-based browser that claims to be faster than stock Chromium and other derivative browsers like Edge, or Opera on Desktop. The last time I saw the performance testing results and methodology was when they first released version 1.0, documented in Brave 1.0 Performance: Methodology and Resultshttps://brave.com/brave-one-dot-zero-performance-methodology-and-results/ with the code used to do the analysis available on Githubhttps://github.com/brave-experiments/browser-comparison-toolkit but I haven't seen more recent data. The tests were done in older versions of the browsers tested and the Brave Browser Comparison Kithttps://github.com/brave-experiments/browser-comparison-toolkit hasn't been updated for newer versions not that...

Continue reading →

Custom Loops in WordPress

When researching how to use Gutenberg Ramp to partially allow Gutenberg on a WordPress site, I decided that I wanted to use a custom post type for the test so I wouldn't screw up the existing content for my blog. There is a problem with this idea. Custom post types don't appear in the default loop of a WordPress type so they wouldn't appear along with regular posts on the blog homepage. Most times, this is what we want. We want to use the custom post types on their own specialized loops. However, in this case, it is not what...

Continue reading →

Partial Gutenberg in WordPress with Gutenberg Ramp

As much as I dislike Gutenberg, mostly because of the amount of duplicated work it makes you do, there are times when it would be nice to have it for some things but not for others. While researching alternatives to Gutenberg I discovered the Gutenberg Ramphttps://wordpress.org/plugins/gutenberg-ramp/ plugin. It presents an interesting way to grow how you use Gutenberg that lies no use with plugins like Classic Editor and full use letting Gutenberg be the default editor. For this experiment we'll do the following: 1. Create a custom post type for essays 2. Install Gutenberg Ramp and configure it to only...

Continue reading →

What to do if you're not ready for Gutenberg?

A question that I've seen frequently in Quora and elsewhere since the Gutenberg editor was announced a few years ago was how to disable it and keep the existing, now classic, editor. Rather than answer the question over and over again I thought I'd document the two alternatives that I now recommend using if Guttenberg is not an option. Why wouldn't Gutenberg be a good option? Even though Gutenberg has been around for a few years, there is no parity with tools like ACF and others. Even though newer versions of ACF provide Gutenberg blocks, the technology is not proven...

Continue reading →

Creating a print stylesheet

I don't hear about this very often but once in a while, I will hear about building print stylesheets so that web pages will look exactly the same in print as they do on screen. While I think the idea is laughable, it made me think about what it would take to make web content printable. This is different than using all of CSS Paged Media as documented in Creating printable content from the webhttps://publishing-project.rivendellweb.net/creating-printable-content-from-the-web/, we might test part of the Paged Mediahttps://www.w3.org/TR/css-page-3/ and Generated Contenthttps://drafts.csswg.org/css-content-3/ specifications but I'm not confident that they'll work in all browsers. What we want...

Continue reading →

Client hints: What they are? How do they work? Why do we need them?

> Thank you to Rowan Merewood@rowanm for his patient explanation and review of this post. Client Hints are a content negotiation tool and can help with making responsive images easier to work with and give you other tools to help create a better user experience. They are a set of HTTP request headers allowing clients to indicate a list of device and browser preferences. Using client hints isn't automatic: servers must tell clients what hints they want clients to send using the Accept-CH accept client hints header: apache Accept-CH: Width, Viewport-Width, Downlink or an equivalent HTML meta element with the...

Continue reading →

Inserting meta tags in the head of a page

When researching client hints, I came across an interesting use case for dynamically inserting meta tags on a Handlebars template based on the route I'm accessing. The different pages of the experiment use different sets of client hints so each needs to request the different hints from the server, an Express application in this case. I wasn't able to do it within Express or Handlebars so I had to hack my way through getting it done with Javascript. We also use local storage to set up a variable when we successfully add the meta tag. If the variable exists then...

Continue reading →

Working with Feature Policies in client-side Javascript

Note: The Feature-Policy header has been renamed to Permissions-Policy and browsers will soon start implementing the change. The document.featurePolicy Javascript object will also change to document.permissionsPolicy. The Feature Policies Javascript API allows our client-side code to query for what features are available and what is restricted by Feature Policies. The Javascript API doesn't replace the Feature-Policy header or the allow attribute of an iframe. You still need to set the header before this will work, or it will work with the default values. The downside is that the current version of feature/permissions policy doesn't support setting the policies in a...

Continue reading →

Testing front end with Mocha and Playwright

I've told myself for a while that I would learn how to write and use tests for front-end code. Most of the code and tutorials I've seen are written for backend code. But using tools like Playwrighthttps://playwright.dev/ together with Mochahttps://mochajs.org/ and the Chaihttps://www.chaijs.com/ assertion library we can build very robust testing for front-end code that works in multiple browsers. Background: Playwright Playwright is Microsoft's browser testing and automation library. It allows you to control a browser: Chrome, Firefox, or Safari WebKit and perform operations as if you were working on the browser directly. Because we support multiple browsers we can...

Continue reading →

Aspect Ratio in CSS

Normally, only some elements have an aspect ratio, for example, images. For them, if only the width, or the height, is specified, the other is automatically computed using the intrinsic aspect ratio. In this example, the browser will calculate the height of the image using the width and the image's intrinsic dimensions. html The aspect-ratio property allows developers to explicitly set the aspect ratio of an element not just those that already have an aspect ratio and use it when one of the measurements is missing. The example below, taken From Una Kravetz codepenhttps://codepen.io/una/pen/BazyaOM shows how this works with a...

Continue reading →