Go back

Browsers on crutches: why Safari and Firefox contain thousands of lines of code for major sites 🩼

How Safari and Firefox apply site-specific hacks for major websites, and what Chrome’s dominance means for other engines.

Browsers on crutches: why Safari and Firefox contain thousands of lines of code for major sites 🩼

Remember the Internet Explorer era, when developers had to write tons of hacks for one browser? History has come full circle, but now it is the other way around. Because of Chrome’s total dominance, other browser engines are forced to adapt to code written exclusively for Google’s standards.

In his blog, Den Odell examines a surprising fact: Safari and Firefox are literally packed with custom code injections for popular websites, just so they… do not break. Popular services such as TikTok, Netflix, Instagram and Reddit often ignore web standards or detect browsers incorrectly, forcing engine developers to add workarounds on the fly.

How it works under the hood:

🌐 Safari: contains a huge Quirks.cpp file, already over 4,000 lines of code! The browser checks the domain the user is visiting, and if it matches something like tiktok.com or reddit.com, it enables specific rendering or event-handling behavior.

🌐 Firefox: uses the built-in WebCompat system extension. You can enter about:compat in the address bar and see an interactive list of “interventions” for specific websites, with the option to disable them.

⚙️ Real examples of these injections:

A fake Chrome inside Firefox. Many websites still check for the window.chrome object before serving an advanced player or optimized script. If Firefox encounters such a site, its WebCompat extension creates global variables on the fly:

// Симуляция окружения Blink внутри Firefox для избранных доменов
window.chrome = { runtime: {}, loadTimes: function () {} };
navigator.vendor = "Google Inc.";

Video workarounds in Safari. Facebook, Twitter and Reddit like to aggressively pause videos as soon as the element leaves the visible area. But this breaks the system’s Picture-in-Picture mode. WebKit has a built-in requiresUserGestureToPauseInPictureInPicture hack that forcibly prevents sites from stopping a video if the user has moved it into a separate window.

The conclusion is disheartening: Chrome has become the new de facto standard. If a site works in Chrome, developers often do not even open other browsers. And the minority, Safari and Firefox, have to spend resources not on innovation, but on manually compensating for other people’s mistakes.

Read the article

Copied