First, here are a couple of related, but not-quite-the-same questions:
- Should I include dependencies for which I have the source as projects in my solution?
- https://softwareengineering.stackexchange.com/questions/35052
Now on to my particular question:
I'm building a small JavaScript library. If run within certain older browsers, part of its functionality will depend on a certain polyfill. For the purposes of an example, let's say this polyfill is the requestAnimationFrame
polyfill.
This polyfill is:
- Well-known: Most JavaScript developers are at least vaguely aware of it.
- Available: Copy-pasteable code snippets of variants of it are all over the place.
- Tiny: It's only a few lines of code, really.
- Endemic: Libraries in the same problem space as mine may have it bundled already.
Obviously, if my library were the only library being used in someone's project, and if part of that code could fail without the polyfill in circumstances likely for the developer's audience, it would make sense to bundle the polyfill with the library.
But in the JavaScript world, particularly in this library's domain, it's possible that the developer already has the polyfill, and that by bundling it, I could be re-polyfilling requestAnimationFrame
for the second, third, fourth time over. (This itself isn't really an issue, since most polyfills by their very nature include a pre-check of the namespace. But, I admit, the thought of the same polyfill appearing multiple times in someone's code bothers me like a painting hung slightly crooked.)
So what is the sensible thing to do? Include it? Or just leave a note in the documentation that says, "By the way, make sure you have the Polyfill X if you need to support Browser Y"?