# Make web part compatible for IE11

I have a web part that works for every browser but not in IE.

It seems to have troubles with "startsWith" which is a function that is not supported in IE11, fair enough. But when I changed the code for a one that is supported by IE11, I still get the same error. Only places where I could find non-supported functions for IE11 is in the temporary .js files. I have tried a gulp clean and run but it doesn't work. How can I make my code compatible/compiled to IE11 friendly code?

You can polyfill String.prototype.startsWith() with the following snippet:

if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
value: function(search, pos) {
pos = !pos || pos < 0 ? 0 : +pos;
return this.substring(pos, pos + search.length) === search;
}
});
}


For SharePoint SPFx web part, you can install polyfill using command below.

npm install --save @pnp/polyfill-ie11


Refer to: Polyfill

• Did this fix the issue? I personally experienced the error because of having a polyfill, it seems startsWith is already being implemented by default SharePoint Online JS since very recently – Cameron Verhelst May 7 at 9:43