In this post, I share a simple client-side JavaScript PubSub system I built. Motivated by the Not-Invented-Here syndrome and the desire for independent UI components, I created a lightweight event manager called EventManager. It allows components to communicate without direct dependencies by publishing and subscribing to named events. While similar to tools like Redux, this approach avoids separate state management, leveraging the browser's existing state. The code is available on GitHub.
Measuring the impact of autofill is crucial. In WebKit/Blink browsers, the -webkit-autofill pseudo-class helps track autofill, but it's not supported in Firefox. I've found a workaround in Firefox using the input event, checking for the absence of keyboard interaction. Ideally, a standardized :autofill pseudo-class and a dedicated onautocomplete event would simplify this process, allowing developers to measure and manage autofill effectively.
In my quest to understand how to detect when a field has been autofilled, I needed a way to monitor the events of an element that doesn't exist yet. I created a helper function, waitForElement, that uses MutationObserver to wait for an element with a specific ID to be added to the DOM. Once the element is added, the promise resolves and returns the element. This, combined with my previously created monitorEvents function, allows me to start logging events on dynamically created elements, getting me closer to solving the autofill detection puzzle.
I needed to figure out how to monitor events on an element (like when a field is autofilled) and Chrome DevTools has a monitorEvents function, but Firefox doesn't. Since I couldn't find an equivalent in Firefox DevTools, I created my own JavaScript function that iterates through an element's properties, finds event listeners (e.g., "onclick"), extracts the event name (e.g., "click"), and attaches a console logger to each event. The code snippet and a corresponding gist are provided.
This blog post asks readers for their opinion on including event announcements related to blog post topics. For example, if a post is about Apple Macs, I wonder if readers would like to know about Mac Expos. Similarly, for a post about World War 2, it asks if announcing related events like commemoration days would be useful. Readers are invited to share their thoughts in the comments or via email.
I'm exploring ways to implement continuous polling of a resource and event dispatching based on its state in JavaScript. Are worker threads, or something similar, achievable in JavaScript? Currently, timer-based triggers seem like the most viable option. Is this an acceptable approach, or are there more efficient and appropriate alternatives?
I previously complained about a click-related bug on Start.com. I'm pleased to report that the Start.com team responded to my email, explaining they're overloaded but plan to fix the issue by replacing the "mouse down" event with a "mouse up" event. I'm happy with their response. Here are links to my previous posts about this issue.