Detect XR Support with JavaScript

A few years ago I wrote an article about how to detect VR support with JavaScript. Since that time, a whole lot has changed. “Augmented reality” became a thing and terminology has moved to “XR”, instead of VR or AR. As such, the API has needed to evolve. The presence of navigator … | Continue reading


@davidwalsh.name | 1 year ago

Detect Browser Bars Visibility with JavaScript

It’s one thing to know about what’s in the browser document, it’s another to have insight as to the user’s browser itself. We’ve gotten past detecting which browser the user is using, and we’re now into knowing what pieces of the browser UI users are seeing. Browsers provide wind … | Continue reading


@davidwalsh.name | 1 year ago

JavaScript print Events

Media queries provide a great way to programmatically change behavior depending on viewing state. We can target styles to device, pixel ratio, screen size, and even print. That said, it’s also nice to have JavaScript events that also allow us to change behavior. Did you know you’ … | Continue reading


@davidwalsh.name | 1 year ago

How to Control CSS Animations with JavaScript

When it comes to animations on the web, developers need to measure the animation’s requirements with the right technology — CSS or JavaScript. Many animations are manageable with CSS but JavaScript will always provide more control. With document.getAnimations, however, you can us … | Continue reading


@davidwalsh.name | 1 year ago

Detecting Fonts Ready

Knowing when resources are loaded is a key part of building functional, elegant websites. We’re used to using the DOMContentLoaded event (commonly referred to as “domready”) but did you know there’s an event that tells you when all fonts have loaded? Let’s learn how to use docume … | Continue reading


@davidwalsh.name | 1 year ago

How to Internationalize Numbers with JavaScript

Presenting numbers in a readable format takes many forms, from visual charts to simply adding punctuation. Those punctuation, however, are different based on internationalization. Some countries use , for decimal, while others use .. Worried about having to code for all this madn … | Continue reading


@davidwalsh.name | 1 year ago

Locate Empty Directories from Command Line

As a software engineer that lives too much of his life on a computer, I like keeping my machine as clean as possible. I don’t keep rogue downloaded files and removes apps when I don’t need them. Part of keeping a clean, performant system is removing empty directories. To identify … | Continue reading


@davidwalsh.name | 1 year ago

How to Extend Prototypes with JavaScript

One of the ideological sticking points of the first JavaScript framework was was extending prototypes vs. wrapping functions. Frameworks like MooTools and Prototype extended prototypes while jQuery and other smaller frameworks did not. Each had their benefits, but ultimately all … | Continue reading


@davidwalsh.name | 1 year ago

How to Use window.crypto in Node.js

I’ve been writing a bunch of jest tests recently for libraries that use the underlying window.crypto methods like getRandomValues() and window.crypto.subtle key management methods. One problem I run into is that the window.crypto object isn’t available, so I need to shim it. To u … | Continue reading


@davidwalsh.name | 1 year ago

Convert Fahrenheit to Celsius with JavaScript

The United States is one of the last bodies that refuses to implement the Celsius temperature standard. Why? Because we’re arrogant and feel like we don’t need to change. With that said, if you code for users outside the US, it’s important to provide localized weather data to use … | Continue reading


@davidwalsh.name | 1 year ago

Create a Thumbnail From a Video with ffmpeg

Creating a thumbnail to represent a video is a frequent task when presenting media on a website. I previously created a shell script to create a preview video from a larger video, much like many adult sites provide. Let’s view how we can create a preview thumbnail from a video! D … | Continue reading


@davidwalsh.name | 1 year ago

Detect System Theme Preference Change Using JavaScript

JavaScript and CSS allow users to detect the user theme preference with CSS’ prefers-color-scheme media query. It’s standard these days to use that preference to show the dark or light theme on a given website. But what if the user changes their preference while using your app? T … | Continue reading


@davidwalsh.name | 1 year ago

How to Use Storage in Web Extensions

Working on a web extension is an interesting experience — you get to taste web while working with special extension APIs. One such API is storage — the web extension flavor of persistence. Let’s explore how you can use session and local storage within your Manifest V3 web extensi … | Continue reading


@davidwalsh.name | 1 year ago

Skip or Only Run a Test with JavaScript Mocha

Whenever I start to feel anxiety about a big change I’m making, I start writing more unit tests. I’ll write down my fear and then write a test that attacks, and eventually relaxes, that fear. There are two actions that I’ve been frequently using with test writing: skipping all bu … | Continue reading


@davidwalsh.name | 1 year ago

Determine Default App for File Type from Command Line

One quality of life improvement any developer can make for themselves is ensuring different file types open in the app they’re most proficient in. If you know me, you know I prefer accomplishing as much as possible from the command line. The duti utility allows users to determine … | Continue reading


@davidwalsh.name | 1 year ago

Set Brave as Default Browser from Command Line

I’ve been a huge fan of the Brave web browser for years. They’re crypto-friendly, provide native ad-blocking features, and even provide Tor integration. Whenever I set up new systems, I automate Brave as the default browser. You can use the following shell command to set Brave as … | Continue reading


@davidwalsh.name | 1 year ago

CSS :autofill

Autofilling HTML input elements is a frequent user action that can drastically improve user experience. Hell, we all autofill for our passwords and address information. But what control do we have when input elements have been autofilled? To add custom CSS styles to inputs whose … | Continue reading


@davidwalsh.name | 1 year ago

Monitor Events and Function Calls via Console

Despite having worked on the very complex Firefox for a number of years, I’ll always love plain old console.log debugging. Logging can provide an audit trail as events happen and text you can share with others. Did you know that chrome provides monitorEvents and monitor so that y … | Continue reading


@davidwalsh.name | 1 year ago

CSS :out-of-range

One aspect of web development I’ve always loathed was working with forms. Form elements have been traditionally difficult to style due to OS and browser differences, and validation can be a nightmare. Luckily the native HTML APIs added methods for improving the form validation si … | Continue reading


@davidwalsh.name | 1 year ago

git Force Push

Rebasing is a frequent task for anyone using git. We sometimes use rebasing to branch our code from the last changes or even just to drop commits from a branch. Oftentimes when trying to push after a rebase, you’ll see something like the following: hint: Updates were rejected bec … | Continue reading


@davidwalsh.name | 1 year ago

Specify Node Versions with .nvmrc

I’ve heavily promoted nvm, a Node.js version manager, over the years. Having a tool to manage multiple versions of a language interpreter has been so useful, especially due to the complexity of Node.js package management. One tip I like to give new developers is adding a .nvmrc f … | Continue reading


@davidwalsh.name | 1 year ago

How to Inject a Global with Web Extensions in Manifest V3

For those of you not familiar with the world of web extension development, a storm is brewing with Chrome. Google will stop support for manifest version 2, which is what the vast majority of web extensions use. Manifest version 3 sees many changes but the largest change is moving … | Continue reading


@davidwalsh.name | 1 year ago

How Plugins Enhance The WYSIWYG Editing Experience (Sponsored)

WYSIWYG editors are one of the core components of any content management system (CMS). A well-coded, feature-filled WYSIWYG HTML editor can distinguish between a CMS users love and one they can’t stand.  While all WYSIWYG editors have a set of basic functionality, the power of pl … | Continue reading


@davidwalsh.name | 1 year ago

JavaScript Event.defaultPrevented

Whether you started with the old on_____ property or addEventListener, you know that events drive user experiences in modern JavaScript. If you’ve worked with events, you know that preventDefault() and stopPropagation() are frequently used to handle events. One thing you probably … | Continue reading


@davidwalsh.name | 1 year ago

7 Ways to Optimize Performance for Your WordPress Site (Sponsored)

The vast majority of blogs, news websites, and information websites run on WordPress. While the WordPress developer team and community do their best to ensure wordPress is performant, there are a number of practices you can implement to keep your site blazing fast. Let’s look at … | Continue reading


@davidwalsh.name | 1 year ago

How to Get Extension Manifest Information

Working on a web extension can be kinda wild — on one side you’re essentially just coding a website, on the other side you’re limited to what the browser says you can do in the extension execution environment. One change in that environment is coming January 2023 — pushing extens … | Continue reading


@davidwalsh.name | 1 year ago

How to Reverse an Animated GIF

Modifying visual media via code has always been a fascination of mine. Probably because I’m not a designer and I tend to stick to what I’m good at. One visual effect I love is seeing video reversed — it provides a sometimes hilarious perspective on a given event. Take this revers … | Continue reading


@davidwalsh.name | 1 year ago

CSS :optional

A decade ago HTML and CSS added the ability to, at least signal, validation of form fields. The required attribute helped inform users which fields were required, while pattern allowed developers to provide a regular expression to match against an ‘s value. Targeting required fie … | Continue reading


@davidwalsh.name | 1 year ago

Get a Random Array Item with JavaScript

JavaScript Arrays are probably my favorite primitive in JavaScript. You can do all sorts of awesome things with arrays: get unique values, clone them, empty them, etc. What about getting a random value from an array? To get a random item from an array, you can employ Math.random: … | Continue reading


@davidwalsh.name | 2 years ago

Legacy String Methods for Generating HTML

I’m always really excited to see new methods on JavaScript primitives. These additions are acknowledgement that the language needs to evolve and that we’re doing exciting new things. That being said, I somehow just discovered some legacy String methods that you probably shouldn’t … | Continue reading


@davidwalsh.name | 2 years ago

Interview with an Intiface Haptics Engineer

I was recently re-reading my Interview with a PornHub Web Developer and one bit I started thinking about was the VR question and the idea of making users not just see but feel` something. The haptic feedback of VR games is what really sets them apart from your standard PC or cons … | Continue reading


@davidwalsh.name | 2 years ago

Input valueAsNumber

Every once in a while I learn about a JavaScript property that I wish I had known about years earlier — valueAsNumber is one of them. The valueAsNumber provides the value of an input[type=number] as a Number type, instead of the traditional string representation when you get the … | Continue reading


@davidwalsh.name | 2 years ago

Advanced Code Display with Code Detection API (Sponsored)

Web apps are accepting numerous types of inputs, from basic text to code to imagery, files, and more. It’s important that we validate the contents we receive but if you do allow arbitrary text, it’s good to know what exactly has been submitted so you can present it properly. Ente … | Continue reading


@davidwalsh.name | 2 years ago

CSS :has

For as long as developers have written CSS code, we’ve been desperate to have a method to allow styling a parent element based child characteristics. That’s not been possible until now. CSS has introduced the :has pseudo-class which allows styling a parent based on a relative CSS … | Continue reading


@davidwalsh.name | 2 years ago

Flexible, Powerful DataGrad from Sencha (Sponsored)

Many of the web functionalities that we rely on once lived within individual desktop applications. From office suites, games, and financial tools, all of them are now web applications; they’re just as feature packed as their desktop counterparts. In the past I’ve used a variety o … | Continue reading


@davidwalsh.name | 2 years ago

Confessions of a Web Developer XIX

It's been a while since I've gotten a few things off of my chest and since I'm always full of peeves and annoyances I thought it was time to unleash: Due | Continue reading


@davidwalsh.name | 2 years ago

Simplify Your File Handling With Filestack Workflows (Sponsored)

Automation is a really important skill for engineers, especially when it comes to working with various file types. The more you accept for input, and the | Continue reading


@davidwalsh.name | 2 years ago

Detect Dark Mode Preference with JavaScript

Seemingly every website, dapp, and app offers a dark mode preference, and thank goodness. Dark mode is especially useful when I'm doing late night coding, | Continue reading


@davidwalsh.name | 2 years ago

JavaScript Class Privates

One of my aspects of JavaScript that drew me to it as a young developers was that its syntax was loose and I could code quickly. As you gain experience as | Continue reading


@davidwalsh.name | 2 years ago

Easy Asset Access with the Cloudinary Media Library Browser Extension

Readers of my blog will know that I've been banging the Cloudinary drum for years. Their awesome media capabilities allow users to optimally deliver | Continue reading


@davidwalsh.name | 2 years ago

I Love You, Ringo

Some things happen in your life at exactly the right time. It could be meeting the right person, discovering an open source project you go on to join, or | Continue reading


@davidwalsh.name | 2 years ago

Amazing Text Editing Experiences with UltraEdit (Sponsored)

There's a common saying that adults spend more time with coworkers than family; for us software engineers, we spend more time with our text editor than | Continue reading


@davidwalsh.name | 2 years ago

More Awesome Git Aliases

In the last article in this series, Awesome Git Aliases, we took a look at some awesome aliases for Git. However, the true power of Git aliases comes from | Continue reading


@davidwalsh.name | 2 years ago

Immediately Executing setInterval with JavaScript

Employing setInterval for condition polling has really been useful over the years. Whether polling on the client or server sides, being reactive to | Continue reading


@davidwalsh.name | 2 years ago

How to Flatten git Commits

One of my least favorite tasks as a software engineer is resolving merge conflicts. A simple rebase is a frequent occurrence but the rare massive conflict | Continue reading


@davidwalsh.name | 2 years ago

JavaScript String replaceAll

Replacing a substring of text within a larger string has always been misleading in JavaScript. I wrote Replace All Occurrences of a String in JavaScript | Continue reading


@davidwalsh.name | 2 years ago

Froala: The Next Generation WYSIWYG Editor (Sponsored)

There are a number of utilities required to really power a content management system and its users. One of the most important utilities is a performant, | Continue reading


@davidwalsh.name | 2 years ago

Log a User Out from Command Line

Automation is a system administrator, support agent, and tech savvy person's dream. Automating tasks via scripts remotely helps to get clients out of | Continue reading


@davidwalsh.name | 2 years ago