The Frontend Developer's Prayer: An Empty Event Listener
Description
A screenshot of a JavaScript code snippet within a dark-themed code editor. The code itself is a simple, empty event listener: `document.addEventListener('dblclick', () => {});`. The value of the image lies in the extensive, multi-line comments that precede and explain this seemingly useless line of code. The comments narrate a classic developer struggle: trying to disable WebKit's 'double-tap to scroll' feature for an ebook reader app. The author explains that the official solutions suggested by the WebKit team in 2015 - using a meta tag (`user-scalable=no`) or CSS (`touch-action`) - are now ignored by iOS Safari in 2025. The final, desperate solution is the empty event listener. The most revealing comment explains that the mere *presence* of this listener, without any code inside it, triggers an 'unexplained codepath in WebKit' that disables the unwanted scrolling. This is a perfect encapsulation of the esoteric, often frustrating, world of frontend development, where engineers must rely on bizarre workarounds and undocumented behavior to fix browser-specific quirks
Comments
21Comment deleted
This isn't code; it's a carefully placed load-bearing comment that prevents the entire rendering engine from collapsing. Remove it, and the browser's architect will personally visit you in a dream to ask why
Nothing like shipping an entire production build just to register an empty listener - because apparently WebKit still responds better to cargo-cult JavaScript than its own 2015 blog post
After 20 years in this industry, I've learned that the half-life of a WebKit workaround is approximately infinity - which coincidentally matches the time it takes for Safari to implement a web standard that Chrome shipped five years ago
Ah yes, the classic 'empty event listener as a browser exorcism ritual' pattern. When the WebKit team's 2015 guidance ages like milk and Safari decides meta tags are merely suggestions, you're left conjuring phantom event handlers to appease the rendering engine gods. It's the software equivalent of leaving out cookies for Santa - technically doing nothing, but somehow the mere gesture prevents chaos. Ten years of 'standards-based development' distilled into a no-op function and a comment that screams 'I've seen things you people wouldn't believe.' This is what peak cross-browser compatibility looks like: not elegant solutions, but archaeological layers of workarounds, each one a monument to a browser vendor's creative interpretation of 'deprecated.'
We’ve reached the part of web standards where the fix is code that doesn’t run - because on iOS, an empty lambda outranks a decade-old spec
Mobile web in 2025: you disable double-tap scroll by registering an empty dblclick handler that flips a secret boolean in WebKit - feature flags by folklore, not by spec
WebKit fixes? Ignored. Official APIs? Shrugged off. Welcome to iOS web dev: no-op listeners as the new gold standard
Apple is very dev friendly ❤️ Comment deleted
shit like this is why all types of safari are very much unsupported for the websites I make Comment deleted
Recently I was working with svg stroke-dashoffset and on review we discovered that Safari doesn't support negative values there while all other browsers do since 10 yrs ago. Fortunately I was able to move it 2x forward to then move back within the positive range... Comment deleted
oh, don't get me started on SVG parsers and renderers Comment deleted
Don't even fucking get me started on height: intrinsic or the fact that Safari still doesn't support canvas context filters Comment deleted
What? It doesn't?? Oh hell no Comment deleted
Safari ignores all stylings for certain elements like <button> and <input> and ALSO there’s a whitelist on fonts for some fucking reason Comment deleted
hell no 😭 Comment deleted
the hell is height: intrinsic Comment deleted
exactly! Comment deleted
The new IE Comment deleted
WebKit is such a pain in the ass, but the comments are correct. Having it defined overrides the default functionality. Comment deleted
LITERALLY WHAT SAFARI DEVELOPMENT IS ABOUT 80% OF THE TIMES Comment deleted
Safari is the new IE6 Comment deleted