Hacker News new | ask | show | jobs
by cosmic_cheese 301 days ago
I hope some form of include makes it into the HTML standard and popular browser implementations before XSLT is gone. It’s perhaps the single largest gap in HTML’s capabilities and could reduce need for SSR, JS, and a build step in a lot of circumstances. Until now XSLT has been able to fill that gap for those who need that capability, but if it’s going away…
3 comments

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.
That’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.
We should drop HTML and CSS files as well, because you can just use JS to create DOM nodes and set styles on them.
One of the greatest features of pdf is that js support is unreliable.
It'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.
The point is to take JS implemented features and make them native to the browser.
That's a terrible point.
Not 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.
> 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

Interesting. Not a bad proposal, but am I reading correctly that partials from a different URL (“includes”) is a someday thing rather than part of the initial spec?

Either way it’d allow several types of sites to have zero dependencies and no build step which is pretty cool.

Remember shtml which was supposed to be server side include? It never made it to the web browser.