Skip to content
DevMeme
6403 of 7590
Frontend Post #7024 · source on Telegram

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

21
Anonymous ★ Top Pick 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
  1. Anonymous ★ Top Pick

    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

  2. Anonymous

    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

  3. Anonymous

    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

  4. Anonymous

    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.'

  5. Anonymous

    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

  6. Anonymous

    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

  7. Anonymous

    WebKit fixes? Ignored. Official APIs? Shrugged off. Welcome to iOS web dev: no-op listeners as the new gold standard

  8. @SpYvy 1y

    Apple is very dev friendly ❤️

  9. @RiedleroD 1y

    shit like this is why all types of safari are very much unsupported for the websites I make

  10. @NaNmber 1y

    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...

    1. @RiedleroD 1y

      oh, don't get me started on SVG parsers and renderers

  11. @Algoinde 1y

    Don't even fucking get me started on height: intrinsic or the fact that Safari still doesn't support canvas context filters

    1. @pooyabehravesh 1y

      What? It doesn't?? Oh hell no

    2. @ownedbywuigi 1y

      Safari ignores all stylings for certain elements like <button> and <input> and ALSO there’s a whitelist on fonts for some fucking reason

      1. @NickNirus 1y

        hell no 😭

    3. @RiedleroD 1y

      the hell is height: intrinsic

      1. @Algoinde 1y

        exactly!

  12. @dsmagikswsa 1y

    The new IE

  13. @Valithor 1y

    WebKit is such a pain in the ass, but the comments are correct. Having it defined overrides the default functionality.

  14. @ZgGPuo8dZef58K6hxxGVj3Z2 1y

    LITERALLY WHAT SAFARI DEVELOPMENT IS ABOUT 80% OF THE TIMES

  15. @Diotost 1y

    Safari is the new IE6

Use J and K for navigation