Skip to content

Instantly share code, notes, and snippets.

@appkr
Created April 2, 2015 00:53
Show Gist options
  • Save appkr/f7501f9119b09cdbeac9 to your computer and use it in GitHub Desktop.
Save appkr/f7501f9119b09cdbeac9 to your computer and use it in GitHub Desktop.
Polymer/Webcomponents conditional polyfill
<script>
if ('registerElement' in document
&& 'createShadowRoot' in HTMLElement.prototype
&& 'import' in document.createElement('link')
&& 'content' in document.createElement('template')) {
// We're using a browser with native WC support!
} else {
document.write(
'<script src="https:\/\/cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/0.6.0/webcomponents.min.js"><\/script>'
);
}
</script>
<link rel="import" href="my-custom-component.html">
<!-- credit to Glen Maddern, https://github.com/geelen/x-gif -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment