3 ms·
I don't see how the template element is something special, can't you use that Javascript on any container?
by UberMouse 14y ago
I don't see how the template element is something special, can't you use that Javascript on any container?
- Mahn 14y agoI suppose it's just for semantic purposes, just like the "article" element; ie, to make the markup pretty.
- patrickaljord 14y agoFTA: > The element allows you to store HTML fragments that you intend to use for any reason at any time during the lifetime of your page, but that aren’t ready or shouldn’t be used during page load. It's faster because it's not interpreted until it's actually being used. Think of all these mustache templates or display: none elements that are not needed on page load.
- JoshTriplett 14y agoNot just to make the markup pretty. It also means that if you view the page without scripting, or with a screen reader, you'll get results that make sense. And it means that robots, scrapers, indexers, and search engines can actually see the template content, which they can't easily do if you embed it in Javascript document.createElement calls.
- defen 14y agoThe <template> element and the Object.observe method both seem tailor-made for speeding up angular.js based apps.