Dublin Library

The Publishing project

Permissions policy and API

The Permissions APIhttps://developer.mozilla.orghttps://developer.mozilla.orgWeb/API/PermissionsAPI/UsingthePermissionsAPI gives use the ability to request permission from the user to use a given web API. This is an update of the 2020 posts Feature Policieshttps://publishing-project.rivendellweb.net/feature-policies/ and Working with Feature Policies in client-side Javascripthttps://publishing-project.rivendellweb.net/working-with-feature-policies-in-client-side-javascript/. Feature policies have been renamed to Permissions API and the API may have changed since the original articles were posted In this post we'll look at the Permissions API, how it works, how it's different from other APIs like geolocation that provide their own permissions, how is this different than using Content Security Policies, and how to incorporate it into your projects. What...

Continue reading →

Revisiting CSS Custom Properties

CSS variables are awesome, particularly when implemented using the @property at-rule but we need to remember that there can be too much of a good thing. This post will talk about how to define custom properties using @property, the differences between using @property and regular custom properties and some cases where we can have too many properties. Revisiting @property There are two ways to declare custom properties in CSS. The original is to just declare it and initialize it in one declaration: css :root { --color-background: oklch1 0 106; } We can then use the variable everywhere we want: css...

Continue reading →

Centering things with CSS

Centering content, particularly vertical centering, has always been very challenging to me. The old way These are some techniques to center content using CSS before Flexbox. Aligning text Aligning text is easy. We use something like this to center align all paragraphs: css p { text-align: center; } or a class to center specified content: css .center { text-align: center; } Centering Content My favorite trick to center larger blocks of content is to use margin attributes with the auto value. If you use the two-value margin declaration then you need to remember that the first value is for the...

Continue reading →

Improving performance of a WordPress site (2): Optimizations

Now that we've set up the baseline, let's see how much we can improve it. Enable a cache plugin We will first install a Cache Plugin to make easier to cache different portions of the website. I will use W3 Total Cachehttps://wordpress.org/plugins/w3-total-cache/ with the default settings. | Source | Form Factor | Performance | Best Practices | Accessibility | SEO | PWA | | --- | --- | :-: | :-: | :-: | :-: | :-: | | PSI | Mobile | 68 | 98 | 100 | 100 | N/A | | PSI | Desktop | 98 |...

Continue reading →

Loading fonts on the web

It surprising to me that we still need to discuss font loading on the web after how long we've been able to load fonts using @font-face. Before we jump in let's do a brief trip down font loading memory lane. In the beginning we didn't have web fonts. We had to rely on web safe fonts that were guaranteed to be installed on most systems. CSS first introduced @font-face in 1998 but it faltered becaue, at the time, it did not providem any level of protection so font foundries were reluctant to let users load their fonts with @font-face so...

Continue reading →

Be mindful of ch units

I think ch units in typography are cool, but there was something about them that I hadn't thought about and is something that may impact your site's performance metrics. This post will explore ch units, what they are and what they do. It will also discuss a problem presented by Silvestar Bistrović in Be careful with ch unitshttps://www.silvestar.codes/articles/be-careful-with-ch-units/ along with a possible solution. What are ch units According to the W3C's CSS Values and Units Module Level 3https://www.w3.org/TR/css-values-3/length-advance-measure candidate recommendation, the 'ch unit': > Represents the typical advance measure of European alphanumeric characters, and measured as the used advance measure...

Continue reading →

Brotli compression streams

In a previous posts, I discussed the basic of streams and how to use them,how to use them in service workers, and how to build custom streams. This post will cover an additional area of interest: Using Brotli compression in streams. Using Brotli compression The streams API supports GZIP and Deflate. There are other compression algorithms that are worth looking at, in particular Brotlihttps://en.wikipedia.org/wiki/Brotli. > Brotli is a lossless data compression algorithm developed by Google. It uses a combination of the general-purpose LZ77 lossless compression algorithm, Huffman coding and 2nd-order context modelling. Brotli is primarily used by web servers and...

Continue reading →

Scopped CSS

Scopped CSS has been a hot topic in front-end development. It is designed to give you tighter control over your styles and how they interact with each other. The @scope at-rule The @scope root at-rule declares a scoping root and optional scoping limits associated with a set of style rules. Using the @scope at-rule we can specify: Rules that apply to all elements in the scope using the :scope seelector Rules that apply to specific elements in the scope that will override the default rules This example defines a scope of .card. All elements with a the class will be...

Continue reading →

Improving performance of a WordPress site (1): Getting ready

Performance is important. Performance will keep people coming back to your site. Performance is very hard to get right, specially for mobile devices. I'm particularly interested in seeing how my blog https://publishing-project.rivendellweb.nethttps://publishing-project.rivendellweb.net does in mobile. The first step is to check what the browser tells me: Running PageSpeed Insightshttps://pagespeed.web.dev/ will produce both mobile and desktop reports. What I find most interesting is the differences between mobile and desktop and between runs on different browsers. It also provides both the results of the Chrome User Experience CrUXhttps://developer.chrome.com/docs/crux/ for the site and the artificial results from Lighthouse. Unfortunately, there is no CrUX...

Continue reading →

Creating color palettes with color-mix()

Since color-mixhttps://developer.mozilla.org/en-US/docs/Web/CSS/colorvalue/color-mix is now available in all browsers we can revisit what it is, how it works and one possible use in creating a customizable color palette. What is color-mix The color-mix function allows you to combine 2 colors, in a given color space, with the specified percentages of each color. The most basic usage uses only the color space and the two colors css .demo01 { background: color-mixin oklab, red, blue; } You can use percentage values to indicate how much of each color to apply to the mix. If you specify a percentage value, it will be subtracted...

Continue reading →