Search code examples
javascriptreactjsinternet-explorermicrosoft-edgepolyfills

Best place in project to put a file with polyfill for cross-browser JavaScript support


Wondering where in a React / Redux app (created using create-react-app) is the optimal place to locate/place any files that will serve as custom polyfills for browsers that lack support. Specifically, I need to be able to use Array.prototype.includes and String.prototype.startsWith, along with a few other methods that aren't supported in Internet Explorer or Microsoft Edge. Any suggestions are appreciated!


Solution

  • After you eject your React/Redux app (created using create-react-app), you should find the polyfills.js at /config folder.

    Then you can add your polyfill codes, or use those suggested by Mozilla Developer Network:

    Array.prototype.includes()

    String.prototype.startsWith()

    I hope above does help.