Smashed plates on the ground.
Photo by CHUTTERSNAP on Unsplash

JS compatibility with IE11

Unfortunately, even at the end of 2019, it's been reported that IE11 is still used by almost 4% of total internet users in United States. 4%, while small, is still statistically significant. Significant enough to worry about fatal errors in your code.

For example, a data capture popover that covers the whole page, but will not submit or even close in IE11. Which is unfortunately the situation I encountered today. One helpful stackoverflow comment specifies:

Recently I had the issue when my ES6 code does not work at IE11.
I had used IIFE, arrow functions and const.
I convert my code via the Babel recompiler and that helped me out to get everything to work just like in Chrome.

So basically, write your JS like you're living in the past. It's a simple fix: use a convertor or rewrite your code without the features above.

Example:

// code that doesn't work in IE11
const closeModal = e => {
  overlay.classList.add("content--hide");
};
    
// code that does work in IE11 with arrow function removed
var closeModal = function(e) {
  overlay.classList.add("content--hide");
};

A little digital blog, by a little analog person

© 2021 Ashley Chin