Hacker News new | ask | show | jobs
by matchagaucho 3539 days ago
Given "fetch" is not yet a standard, jQuery $.ajax is actually a decent cross-browser polyfill.
2 comments

I've been out of the JS world for a few years, but for a single Ajax call, why wouldn't you use XMLHttpRequest?
jQuery ajax essentially is just a wrapper to XMLHttpRequest.

With some effort, the relevant jQuery methods that act as polyfills could be extracted.

However, a minified version of core jQuery is < 20Kb. A very low technical debt trade-off to support 99% of browsers.

Why would you care about IE8 - 9 or whatever other browser you might be thinking about that has probably an infinitesimal market share?
Market share might be a ridiculously small percentage overall, but it's never appropriate to dismiss compatibility outright.

Reasons to include inefficient code for compatibility reasons might include applications where maximum reach is valuable, or where the scale is so large that the "infinitesimal market share" percentage plays out into thousands of end users.

Because market share is only meaningful if you target consumers. If you write (internal or niche) web applications for e.g. schools, large companies, non-profits etc. legacy browsers can easily be > 30% of your targets.