4 ms·
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 hav
by moffkalast 4y 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.
- polskibus 4y agoIs <script type="module" /> not sufficient for your needs? If not then what is missing?
- nkozyra 4y agoSeems to be arguing for modular layout/templating, which is what virtual includes did (the cgi in the example would hypothetically output html)
- lkschubert8 4y agoWouldn't the include still need some templating functionality? Or are people using vue that heavily for just importing static html?
- ear7h 4y agoNot 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.
- TheAceOfHearts 4y agoHTML 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.
- elcritch 4y agoFirefox refused the proposal as well. ESM requires javascript though. :/
- moffkalast 4y agoMy admiration for Mozilla and Apple grows every day /s
- Narishma 4y agoSame, but without the /s
- stevekemp 4y agoIt'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.
- andai 4y ago<?php require("somemodule.html"); ?>
- agumonkey 4y agoI 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
- marwis 4y agoIt's always been possible: <script>document.write(`<p>foo</p>`)</script>
- agumonkey 4y agoGood point, but it's very different in terms of thinking. Same as structural versus string macros in programming languages.
- marwis 4y agoYou can do it with custom elements, e.g. <dom-calc> const p = document.createElement('button'); p.innerText = 'hi'; p.onclick = () => alert('hi'); return p; </dom-calc> For something like: class CalcElement extends HTMLElement { connectedCallback() { setTimeout(() => { const fn = new Function(this.innerText); this.replaceWith(fn()); }, 0); } } customElements.define('dom-calc', CalcElement);
- tirpen 4y ago> https://caniuse.com/imports https://caniuse.com/imports It was a feature in Chrome 36-79 and there were working polyfills to make it work on other browsers. It was actually a great feature and I used it extensively on an old project back then. CanIUse: https://caniuse.com/imports https://caniuse.com/imports (Now obsolete) tutorial: https://www.sitepoint.com/introduction-html-imports-tutorial/ https://www.sitepoint.com/introduction-html-imports-tutorial...
- xigoi 4y agoHow would <include> be useful for dynamically updating the DOM based on data, which is the main point of Vue?