Skip to content

Instantly share code, notes, and snippets.

@justinribeiro
Created March 14, 2016 22:12
Show Gist options
  • Save justinribeiro/79e860fe4b2bb2fa71c9 to your computer and use it in GitHub Desktop.
Save justinribeiro/79e860fe4b2bb2fa71c9 to your computer and use it in GitHub Desktop.
Check for need for WebComponents polyfill, use Shadow DOM.
var webComponentsSupported = ('registerElement' in document
&& 'import' in document.createElement('link')
&& 'content' in document.createElement('template'));
if (!webComponentsSupported) {
var script = document.createElement('script');
script.async = true;
script.src = '/bower_components/webcomponentsjs/webcomponents-lite.min.js';
document.head.appendChild(script);
window.addEventListener('WebComponentsReady', function(e) {
console.log('Fallback time! WebComponentsReady() fired and components ready.');
});
} else {
window.Polymer = window.Polymer || {dom: 'shadow'};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment