3 ms·
There is no point of introducing yet another standard to do something that can be done in few lines of JS. customElements.define( "html-include",
by samdoesnothing 1y ago
There is no point of introducing yet another standard to do something that can be done in few lines of JS.
customElements.define(
"html-include",
class extends HTMLElement {
connectedCallback() {
fetch(this.getAttribute("href"))
.then((response) => response.text())
.then((text) => (this.innerHTML = text))}});
The browser has had a powerful scripting language built in as a core primitive for decades, and yet people would rather create more standards to avoid using it for ideological reasons, and then complain that there aren't enough competing browsers.
- sugarpimpdorsey 1y ago> yet people would rather create more standards to avoid using it for ideological reasons Uh the standard in question has existed for over two decades
- cosmic_cheese 1y agoThat’s not nearly as nice as being able to drop a… <include src="/shared/header.htmp”> …in anywhere you want a header. It being part of HTML also allows engines to optimize in ways that otherwise wouldn’t be possible and implement user-toggleable features like lazy loading. It can get better as browsers get better and is less likely to break than any custom JS I write.
- layer8 1y agoWe should drop HTML and CSS files as well, because you can just use JS to create DOM nodes and set styles on them.
- 6510 1y agoOne of the greatest features of pdf is that js support is unreliable.
- naniwaduni 1y agoIt's something that people keep reinventing on both sides of the connection. That XSLT is the better of two terrible ways to do it, and that you're making the argument that the other one still exists, is an embarrassment.
- nashashmi 1y agoThe point is to take JS implemented features and make them native to the browser.
- samdoesnothing 1y agoThat's a terrible point.
- cosmic_cheese 1y agoNot at all. The existence of general purpose scripting isn't and shouldn’t be at odds with equipping HTML to handle a few very common, very basic tasks without JS. There’s plenty to be gained by doing so, including better ergonomics and efficiency. Even heavy JS apps stand to benefit since it’s that much less code to have to write and maintain.