New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please revisit HTML Imports #677
Comments
Hi @matthew-dean! You'll hopefully be happy to know that they are being revisited, see #645 for the ongoing discussion. |
@matthewp That's great! Although it's a little disappointing that the conversation is so focused on a JavaScript-based solution. 😞 I mean ES6 modules are great but they're just not necessary to declare an HTML import. It looks like people are very focused on injecting Webpack-like syntax into JavaScript. |
That conversation has several different threads of ideas so it's hard to follow, but I don't think any of them require that you use JavaScript to import HTML. One idea would make this work: <script type="module" src="./path/to/element.html">
<my-element></my-element> Of course, |
@matthewp Hmm, I see. Well, that's better than nothing. |
I don't think anyone thinks it's not important. It's just that new mechanism to import & integrate a separate HTML document requires a well thought out solution. Right now, we're exploring what the declarative syntax for custom elements should look like, and that should help us guide what the importation mechanism should be. Relatedly, it would be great if you can enumerate a list of concrete use cases (not some generic description of what API you want but a concrete user/developer scenario). |
Thanks @matthew-dean for raising your interest and concerns! I'll close this in favor of #645 but your voice is certainly heard. |
@TakayoshiKochi @rniwa Thanks for listening. And I hope that declarative HTML Imports could be considered for replacing unnecessary server-side templating solutions someday. |
I think this issue should leave on its own, as @matthew-dean clearly explained the problem at stake in the quote above. |
@Kuzcoo I don't believe HTML Imports did anything useful without JavaScript iirc. I think others agree that being able to define components using only HTML/CSS is a good goal (I do!). I think you might be thinking that because HTML modules goes through the JavaScript module system that it means they are for JavaScript oriented sites (SPAs if you will) but that's not the case. They serve the same use case as HTML imports, just use a different mechanism. |
@matthewp : ok. If we could just link the html fragment and use it as such Also, it looks counterintuitive to need js to serve HTML. |
Exactly. It's counter to the existing platform. HTML should be imported via other HTML declarations. To the extent it's created via JS, JS should create the HTML import, and that import should have a DOM interface to get access to the imported tree. But |
You can use |
@domenic : do we still have to execute Furthermore, here we assume the .html snippet is a JavaScript module.
|
I'm disappointed by the industry rejection of HTML Imports. IMHO the web has needed declarative HTML imports since HTML 1.0. The lack of it has been the reason why so many server-side templating languages have needed to exist, when their only reason for being has been that web pages can re-use all assets across pages (JS and CSS) except for other HTML partials.
I think one of the reasons for this rejection is that the use-cases for HTML imports have been so narrowly scoped to defining custom elements. But the reason to have HTML imports extends far, far beyond web components to the fundamentals of web page construction.
I think if HTML Imports could be redefined with a broader scope, it would be more obvious to vendors that ES6 JS Modules are not a sufficient replacement for the power of what HTML Imports can do. (And maybe that's only because the current editor's draft is not flexible enough to be used for importing partials declaratively?)
The text was updated successfully, but these errors were encountered: