The polyfills are a way to use modern code in ancient browsers, but knowing exactly what should be treated is very difficult there Mozilla created Polyfill as a Service.
It basically works like this; you insert a script whose URL points to this service and next to the request of the script the browser sends the header user-agent that identifies which browser the user is using, and based on this information is served a script that makes the polyfill of modern features that your browser does not contemplate.
Unlike modernizr that only detects the features that are missing this service actually fills in the gaps.
If you want to hack into the project the repository on Github is this one; https://github.com/Financial-Times/polyfill-service
I have not tested this service but it seems VERY promising.
I use the Modernizr to test if the browser has new HTML and CSS features. That article may be useful.
– Renan Gomes