- Is a feature available?
MDNhttps://developer.mozilla.org/en-US/- check feature article, browser support table at the bottom
- often includes notes, fallbacks, workarounds (if support is missing)
caniuse.comhttps://caniuse.com/- search for feature name to get a detailed overview table (incl. browser market shares)
- often includes notes, fallbacks, workarounds (if support is missing)
google- google with keywords
- for more complex issues,
Stackoverflowdiscussions can be helpful
ES6/JS Compat Tablehttps://kangax.github.io/compat-table/es6/- for next-gen JavaScript syntax features, check overview tables
- provides detailed feature split and also includes support of transpilers
const button = document.querySelector('button');
const p = document.querySelector('p');
button.addEventListener('click', async () => {
const text = p.textContent;
try {
// detect if navigator.clipboard is supported or not
if(navigator.clipboard) {
const result = await navigator.clipboard.writeText(text)
console.log(result)
} else {
alert('Copy feature not available')
}
} catch (error) {
console.log(error)
}
}Polyfillsare third-party packages that add a functionality that otherwise would be missing in the browserBabelcan use a packagecore-jsthat can automatically detect non supported things and add polyfills for them while transpilation
- convert (
transpile) modern code to older code - third-party tools like
Babelconvert your code to code that works in older browsers as well