So I've recently been reading through the ResourceLoader startup code looking for ways to improve it, and one of the things I spotted is the list of features we check for to determine if a browser supports JavaScript
function isCompatible( ua ) { return !!( // https://caniuse.com/#feat=es5 // https://caniuse.com/#feat=use-strict // https://caniuse.com/#feat=json / https://phabricator.wikimedia.org/T141344#2784065 ( function () { 'use strict'; return !this && Function.prototype.bind && window.JSON; }() ) && // https://caniuse.com/#feat=queryselector 'querySelector' in document && // https://caniuse.com/#feat=namevalue-storage // https://developer.blackberry.com/html5/apis/v1_0/localstorage.html // https://blog.whatwg.org/this-week-in-html-5-episode-30 'localStorage' in window && // https://caniuse.com/#feat=addeventlistener 'addEventListener' in window && // Hardcoded exceptions for browsers that pass the requirement but we don't // want to support in the modern run-time. // // Please extend the regex instead of adding new ones! // And add a test case to startup.test.js !ua.match( /MSIE 10|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass|^Mozilla\/5\.0 .+ Gecko\/$|googleweblight|PLAYSTATION|PlayStation/ ) ); }
Do we still need to check for some of these features being around? Looking at use-strict (https://caniuse.com/use-strict) vs queryselector (https://caniuse.com/queryselector), as far as I can tell, all browsers that support strict mode also support queryselector, and so we don't really need to check for queryselector support.
The same is true for addeventlistener (https://caniuse.com/addeventlistener) - all browsers that support strict mode also have addeventlistener.
For the localStorage check (https://caniuse.com/#feat=namevalue-storage), the only browser I see that supports strict mode but not local storage (i.e. the only browser that gets filtered out by also checking for localStorage) is Opera Mini, which would get excluded anyway because of the regex (does this mean we should drop the localStorage check, or remove it from the browser regex?)
For window.JSON (https://caniuse.com/json), all browser that support strict mode have JSON too.
Are these checks still needed? If not, I can send a patch to remove, but I wanted to file a task to discuss this given how critical this is to ensuring we don't try to run JavaScript on unsupported browsers.