HTML Imports are in @FirefoxNightly! about:config > dom.webcomponents.enabled http://t.co/lbRGegTfvz h/t @wilsonpage pic.twitter.com/er1sZ5u5XP
— Addy Osmani (@addyosmani) July 4, 2014
- I've made a demo which can be used for an example for HTML Imports<link rel="import" href="import.html" onload="handleLoad(event)" onerror="handleError(event)">
# onload and onerror are just for logging the status of the page. (If the import page has been loaded or not.)// Thanks to http://www.html5rocks.com/en/tutorials/webcomponents/imports/
var link = document.querySelector('link[rel="import"]');
// Clone the <template> in the import.
var template = link.import.querySelector('template');
var clone = document.importNode(template.content, true);
document.querySelector('#getting-started-info').appendChild(clone);
function handleLoad(e) {
console.log('Loaded import: ' + e.target.href);
}
function handleError(e) {
console.log('Error loading import: ' + e.target.href);
}
# Variables: link used to select the link, template used to select the <template> from the imported page and clone for cloning the <template>'s content.Labels: Chrome, CSS Variables, Firefox, HTML Imports, Opera