Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There used to be a thing for this

https://caniuse.com/imports



No HTML imports was an idea of using the HTML document format to encapsulate the 3 distinct data types needed for custom elements:

- JS for functionality via the custom elements API - HTML for layout via <template> tags. - CSS for aesthetics via <style> tags.

Not for just quickly and simply inserting the contents of header.html at a specific location in the DOM.


Says "superseded by ES modules". Not really the same thing, right?


The article asks about includes but also about imports ("HTML cannot import HTML ") which this is very directly.

This feature was billed as #includes for the web [1]. No, it acts nothing like an #include. TBH I don't see why ES modules are a "replacement" here.

Personally I would like to see something like these imports come back, as a way to reuse HTML structure across pages, BUT purely declaratively (no JS needed).

#includes where partially formed HTML (ie, header.html has a <body> open tag and footer.html has the closing tag) isn't very DOM compatible.

[1] https://web.archive.org/web/20181121181125/https://www.html5...


Chad QQ and UC browsers, the only ones still supporting HTML imports lmao. I've never heard of them before but I like the cut of their jib.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: