1

I've created jquery plugin that is using modern browser's (Node/Element) features. I'm going to publish plugin as npm package. My wish is not to include polyfills code into jquery plugin, bud declare the dependencies on them.

Plugin created using Babel.

What kind of options to declare those dependencies I have? Just list them in documentation and point sample modernizr or polyfill-service configuration? What else? Any recommended automation e.g for webpack or other bundler's users? For babel users?

  • @RobertHarvey dependency on module is not a dependency on polyfill. you can't just write require("classList") because there should be special run time agent who will decide does this runtime need polyfill of 'classList' or not. `webpack-polyfill-injector` is a sample of such agent. but it loads polyfills asnychronously and therefore starts race condition with inline ` – Roman Pokrovskij May 14 '18 at 19:12

2 Answers2

2

First, document the browsers you support. Below that include a section in your documentation about how to support older browsers. Here you can list the features for which pollyfills are required.

Something like:

Supported Browsers

  • Firefox 56+
  • Chrome 65+
  • Safari N+
  • Internet Explorer 11+
  • Microsoft Edge 38+

Supporting Older Browsers

This plugin makes use of the following HTML5 features that older browsers sometimes do not support:

  • Feature 1
  • Feature 2
  • Feature 3

To support older browsers, you will need to include pollyfills for these features.

This allows you to state what your code supports, and let's developers make their own decisions about older browser support as well.

Greg Burghardt
  • 34,276
  • 8
  • 63
  • 114
  • 1
    I'd add just one bit: list the required polyfills for old browsers you want to support and make this distinction clear. Sometimes your plugin won't work in an older browser and the issue isn't simply a missing function. – Adriano Repetti Jun 22 '18 at 13:53
0

Do what bootstrap 4 do: jquery is your polyfill. Bootstrap 4 use only Babel transpilers and babel helpers but not polyfills.

Try to find the way to do the same using jquery.