Dublin Library

The Publishing project

New Media Query Ranges

This is what we're used to do when working with media queries. We use and and or to represent logical comparisons. This example matches viewports that are 30em or larger. css @media screen and min-width: 30em { .element { / Styles go here/ } } It gets more complicated when you're working with multiple, simultaneous, conditions. This query will match when the viewport width is between 30em and 80em larger than 30em and smaller than 80em css @media screen and min-width: 30em and max-width: 80em { .element { / Style away! / } } Media Queries Level 4 introduced the...

Continue reading →

Testing javascript with Node and Chai

When the Node team marked their test runnerhttps://nodejs.org/api/test.html stable in Node 20.0, it reignited my interest in testing code in general and, potentially, in test-driven developmenthttps://en.wikipedia.org/wiki/Test-drivendevelopment This post will cover my experiments with testing using Node's built-in test runner and the Chaihttps://www.chaijs.com/ assertion library with the Chai as promisedhttps://www.chaijs.com/plugins/chai-as-promised/ plugin to better handle promises. Running tests I'm still learning the Chai API and the different ways to run tests. Some of these exercises are trivial, meant to get comfortable with the technology. Others are examples of how to test against external APIs... while WordPress may be overkill, it shows how...

Continue reading →

Be Mindful of Jargon

One of the hardest things for me to do when writing is to avoid jargon or assume that everyone will understand what I mean. In Dealing with Technical or Professional Jargonhttps://www.nngroup.com/articles/technical-jargon/, the author presents an interesting analysis of jargon in technical documents. The first consideration that I find interesting is that jargon is defined by the audience reading the document. In other words, do they understand the term? !Should we use Jargon diagram. Taken from Dealing with Technical or Professional Jargonhttps://www.nngroup.com/articles/technical-jargon/https://res.cloudinary.com/dfh6ihzvj/image/upload/cscale,w500/fauto,qauto/should-we-use-jargon-1 So how do we address jargon on our pages? It all starts with the users. Who is your audience?...

Continue reading →

Adding Audio Feedback Cues To Web Forms

In Speech Synthesis API: computer talkshttps://publishing-project.rivendellweb.net/speech-synthesis-api-computer-talks/ I looked at how to use the Text To Speech portion of the Web Speech APIhttps://wicg.github.io/speech-api/ to enhance error messages in web forms. Since I wrote that the speech portion of the API is now supported in all major browsers so we can take a deeper look at two specific cases where the speech portion of the Web Speech API may be useful. Audio feedback for forms The first example revisits the original idea of providing audio cues for form validation errors in addition to visual cues. The example uses the following HTML: html...

Continue reading →

Running a specific version of Node

One of the biggest pains of working with Node is when either a library you're working with is pinned to a specific version of Node or you must pin your project to a specific version because one or more dependencies will not work in versions after the specified one or so the developers of the library say. This can happen in one of two ways. The supported versions are included in the engines section of the package.json file as an advisory are included in a .nvmrc file Even though neither of these options will stop you from running the package...

Continue reading →

Import Maps Everywhere

Javascript import maps provide a mapping between local names and external modules. Using Import Maps is a two-step process. First, you create a script with a type="importmap" attribute to create the mappings. html { "imports": { "browser-fs-access": "https://unpkg.com/browser-fs-access@0.33.0/dist/index.modern.js" } } You can also reference files in the project's nodemodules folder. html { "imports": { "lodash": "/nodemodules/lodash-es/lodash.js" } } Furthermore, we can map multiple modules inside the path that we're mapping to. For example, lodash has many modules living under the lodash module. We can use a slash after the map to indicate that we also want the content inside the...

Continue reading →

Node's Permission Model

With the release of Node 20, the team introduces an experimental permissions API. There are two types of permission available with this version of the API: - Module-based permissions control which files or URLs are available to other modules during application execution - Process-based permissions control the Node.js process's access to resources. The resource can be entirely allowed or denied, or actions related to it can be controlled The API provides an additional layer of security. I hope that once the API is marked as stable the API would be restrictive by default, like Deno's permission system. In this post,...

Continue reading →

CSS Display, Positioning and Related Concepts

One of the hardest things for me to understand in CSS is positioning: how to position an item the way I want it on the page. Over the years I've found out that there are multiple concepts associated with positioning: Display Box Model Containing Block Parent element Position z-index You can also work with perspective in CSS but that is not part of positioning so it will not be covered in this post Display The display CSS property defines an element is treated as a block or inline element and the layout used for its children, such as flow layout,...

Continue reading →

Understanding Streams

The Streams API adds a set of tools to the web platform, allowing JavaScript to programmatically access streams of data received over the network and process them as desired by the developer. Basic Concepts As part of understanding streams, there are several concepts associated with streams that we need to be familiar with Chunks A chunk is a single piece of data that is written to or read from a stream. It can be of any type; streams can even contain chunks of different types. Most of the time, a chunk will not be the smallest unit of data for...

Continue reading →

Read and Write Files in Node

Reading, writing, and appending to files in Node is not trivial and has at least three different ways to perform each task: callback, sync callback, and promises. We will look at each of these methods for both reading and writing files to disk. To make things easier we use async/await in our promise-based code. This means that we limit our support to Node 14 end of life scheduled for April 2023, Node 16 end of life is scheduled for September 2023, and Node 18 the current release this is less of a concern for me than it used to be....

Continue reading →