What's missing from HTML and CSS?
-
What's missing from HTML and CSS?
-
westbrookreplied to Chromium for Developers last edited by
Access to more native-like functionality when making custom elements. Maybe customized built-ins, or custom attributes, or native elements decomposed to constituent parts surfaces as mixins for use in custom elements.
An "HTML Macro" element or attribute, something like `<template src="repeated-content.html"></template>` that both brings DOM into the module graph (as available) and stamps/delivers it to the page so that we can continue to reduce the need for JS-frameworks!
-
@westbrook @developers `<template src="…" loading="lazy">` would be mega too.
Perfect for content in modals/overlays (e.g. size guides / mini-bags in ecommerce) and below-the-fold dynamic content (e.g. recently viewed and recommended alternative products)
-
@ryantownsend @westbrook @developers I’ve been noodling on https://www.keithcirkel.co.uk/i-html/ which is my take on that pattern.
-
@keithamus @westbrook @developers wow you’ve gone deeeeeep!
-
@ryantownsend @keithamus @developers Wow, sooo deep! Whether we need the deeper dynamic functionality or not is a great set of questions to ask, but something like this that stamps HTML from another place feels like where we should go with an “HTML Module Scripts: Level One”. Wanna pair on an explainer/proposal?
-
@westbrook @ryantownsend @developers I somewhat feel like a platform solution would be very unlikely due to the security implications. It would be a gigantic uphill climb to get anything resembling this. I think a first step is template references (or something) and building up from there. These libraries can perhaps act as a North Star to steer towards, and even if we don’t make it, making them easier to implement can be useful.
-
@keithamus @ryantownsend @developers
I'd be down for a Level 1 that was only collapsing this into HTML: https://codesandbox.io/p/sandbox/n6q2t5?file=%2Ffetch-html.js
We can get into the magic of templates and arguments and whatnot later...
Then a standard issue HTML-first page could be rendered a la:
<template src="/header.html"></template>
<template src="/nav.html"></template>
<template src="/side-nav.html"></template><!-- CONTENT -->
<template src="/footer.html"></template>
🤯
-
@keithamus @ryantownsend @developers
I'd go so far as to suggest that being this were otherwise inert content that there is room for this to be built around a new tag name, being if the browser doesn't support <newtagname> or <template src="..."> then nothing happens in either case. This opens some nice doors not to feel like we have to continue to pack <template> with every request imaginable for content and custom element enhancements.
-
@westbrook @keithamus @developers limiting to same-origin requests (at least initially) would presumably help limit security issues too?