Comment by moffkalast

3 years ago

This reminds me, I'd argue that the explosion of JS frameworks can be mainly blamed on one thing: the lack of an <include src="somemodule.html"> tag. If you have that you basically have 80% of vue.js already natively supported. No clue why this was never added in any fashion. Change my mind.

HTML imports were part of the original concept of Web Components, and I think they were supported in Chrome. If you look up examples of things built with Polymer 1.x, it was used extensively.

It was actually pretty neat, because you could have an HTML file with a template, style, and script section.

Safari rejected the proposal, so it had to get dropped.

But ESM makes it a bit redundant anyway. The end-goal is to allow you to import any kind of asset, not just JS. There have been demos and examples of tools supporting this going back over half a decade at this point.

It's funny I read that and I remember Apache's virtual-include facility:

    <!--#include virtual="/cgi-bin/example.cgi?argument=value" --> 

I used that, back in the day, as an alternative to PHP.

Wouldn't the include still need some templating functionality? Or are people using vue that heavily for just importing static html?

  • Not the parent comment, but my personal use case is for rendering a selectable list. The server side would render a static list with fragment links (ex. `#item-10`) and include elements with corresponding IDs, and a `:target` css rule to unhide the element. This would hopefully be paired with lazy loading the include elements.

    edit:

    My goal is to avoid reloading the page for each selection and rendering all items eagerly. JS frameworks are the only ones that really allow this behavior.

I wonder why there's never been a

    <calc> /* ... compute and return dom element */ </calc>

Basically what php does but with structure and objects instead of a bytestream

in HTML. Or maybe it's been discussed but got left out

How would <include> be useful for dynamically updating the DOM based on data, which is the main point of Vue?

Is <script type="module" /> not sufficient for your needs? If not then what is missing?

  • Seems to be arguing for modular layout/templating, which is what virtual includes did (the cgi in the example would hypothetically output html)