Skip to content

Instantly share code, notes, and snippets.

@Maqsim
Created February 1, 2019 16:58
Show Gist options
  • Save Maqsim/aee5961dcd84d082698ba2895e81a166 to your computer and use it in GitHub Desktop.
Save Maqsim/aee5961dcd84d082698ba2895e81a166 to your computer and use it in GitHub Desktop.
HTML Imports
const links = document.querySelectorAll('link[rel="import"]');
Array.from(links).forEach(link => {
const template = link.import.querySelector('template');
const clone = document.importNode(template.content, true);
document.querySelector(link.getAttribute('destination')).replaceWith(clone);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment