I'm writing scripts which I want to split into several modules. The "baseline" modules will support older browsers, which do not support new syntax such as === and promises.
The "advanced" modules will be loaded if the browser passes a feature-check.
My question is, how do I check if browser supports ===
operator and .then(function(){})
promise syntax without actually using them first, and causing a syntax error in older browsers?
if (/*what goes here*/) {
var script = document.createElement('script');
script.src = '/advanced.js';
script.async = false;
document.head.appendChild(script);
}