javascript
You can subscribe to the javascript tag micro-feed.
There is an experimental specification on the W3C for a navigator.connection Network Information API that provides a rough indication of connection speeds, which you can use to adjust your content. Like many of the modern API proposals, there is concern over it’s use in browser fingerprinting – but hopefully a course-grained version of this will […]
This is going to be a quick one, as I’m writing this down so future me doesn’t have to set fire to several hours of debugging. I’ll explain more background after I give you the answer. If you find you are getting the wrong answer for element sizes, you are probably using this, where elem […]
We all like to log stuff out sometimes and it would be nice if it were as readable as possible when we do. If you are using JSON.stringify to drop out some values and are tired of getting a long line of text, here’s a simple way to get pretty printed output without adding any […]
As my grandma used to say, “there’s only one thing worse than a scroll-linked positioning effect and that’s not being able to scroll at all”. So, with this in mind I have written a temporary fix for the issue in the latest version of HERE Maps that prevents users from scrolling past the map with […]
This is a little funky script to intercept AJAX requests and raise a simple custom event for everything else in your app to listen to. To use this, you just need to listen for a custom event named `AjaxDetected`. The method, url, and any data is passed in the event detail. document.body.addEventListener(‘AjaxDetected’, function (e) { […]
Although it has been abused with an enthusiasm that borders on the insane, there are good reasons to use the Notifications API in your web apps. For example, you write a mail client that allows the user to request notifications for key contacts… if they are browsing your web-based app, they should get notifications. To […]
This is a note-to-future-self as I just threw together a little script to test images on a web page. Specifically, it highlights: Images that are not lazy loaded Images that are much bigger than their display size As images sizes aren’t reliable until the image is displayed, you will need to run it if your […]
This is a quick exploration of how to use Edge Dev Tools to investigate JavaScript execution time issues. We’ll quickly run a performance profile and identify what part of the JavaScript is the “most responsible” for any performance issues. The idea is to show just the quickest way to find the source of an issue, […]
It is pretty well known these days that fiddling with innerHTML is terribly inefficient. It triggers serialization, and it can result in invalid markup. Nevertheless, you’ll still find this being done in many applications. elem.innerHTML = elem.innerHTML + ‘<a href=”https://www.example.com”>Visit Example Dot Com</a>’; // or elem.innerHTML += ‘<a href=”https://www.example.com”>Visit Example Dot Com</a>’; You can avoid […]
This is just a little script I needed to use to increase text size conditionally. It only increases text below a minimum size and leaves everything else. Please also see a more recent post on CSS Clamp! (function () { var minFontSize = function () { $(“.content-zone *”).each(function () { var $this = $(this); if […]