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 didn’t know: there’s a defaultPrevented proptery on events! Consider the following block of code: // Specific to a link const link = document.querySelector('#my-link'); link.addEventListener('click', e =e.preventDefault()); // A larger document scope document.addEventListener('click', documentClickHandler); function documentClickHandler(event) { if (event.defaultPrevented) {// Using the property... more →
Posted in: JavaScript

How Far Can You Travel in 5 Hours?

How Far Can You Go By Train in 5h? is an interactive map which shows you how far you can travel from any European rail station in less than five hours.Hover over any location on this map (within the highlighted area in Europe) and you can view an isochrome layer which shows you how far you can travel by train in hourly increments. The nearest train station (from which travel times are Maps Mania… more →
Posted in: Interactive Maps

Digging to China

If you dig a hole anywhere in the United States then some wag is likely to ask you if you are digging to China. Of course if you could somehow dig a hole through the center of the Earth you wouldn’t end up anywhere near China. You would emerge soaked to the skin in the south Indian Ocean, somewhere between Madagascar and Australia. That is because no point in the contiguous United States has an Maps Mania… more →
Posted in: Interactive Maps

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 some of them! Use Cloudinary WordPress Plugin for Media Cloudinary is the most dynamic media transformation, delivery, and optimization service on the internet. With Cloudinary you can: Deliver optimized images, audio, and video per device, platform, and browser Use the Cloudinary API or querystring parameters to customize media on the fly Take advantage of client side JavaScript libraries to create image viewers,... more →
Posted in: JavaScript

An example of Algolia Search with Alpine.js

As my readers know, I’ve been falling in love with Alpine.js lately and am always on the hunt for more ways to practice using the framework. I thought I’d share an example of how you could use it with Algolia’s JavaScript client. I use that on my search page here with Vue.js, so it wasn’t a terribly difficult thing to rebuild a similar interface in Alpine.js. Here’s how I did it. Raymond Camden… more →
Posted in: JavaScript

The (Not So) Great Salt Lake

The Great Salt Lake in Utah is very, very big. Although it isn’t as big as it used to be. In 1987 the lake was 3,300 square miles in size. Now, in July 2022, the lake is only around 950 square miles in size. While the size of the Great Salt Lake can fluctuate a lot naturally, due to seasonal changes in the weather, it is now undoubrably drying-up because of global warming. You can see how Maps Mania… more →
Posted in: Interactive Maps

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 extensions to move to manifest version 3. I recently got curious about whether other popular extensions had completed the version 3 update. Executing the following command in the background page (manifest version 2) or service worker (version 3) will provide you the extension’s manifest: chrome.runtime.getManifest() The getManifest call returns a large object detailing the extension’s... more →
Posted in: JavaScript
1 57 58 59 60 61 189