If HTML Imports are dead/deprecated what's the best way to import your web component (X-Tag) template?

Deadly 提交于 2019-12-21 03:41:11

问题


I'm working on my first X-Tag application and on it's page it says it's meant to work with Web Component API's such as 'Custom Elements, Shadow DOM, Templates, and HTML Imports'.

I've started working on my templates, but what's the best option to import them, now that HTML Imports have been deprecated?


回答1:


AFAIK, HTML Imports have not been deprecated (or is it new?). It's only Mozilla who said it won't implement it for Firefox. But the polyfill is still available, and supported.

Since ES6 Modules are not implemented yet, I would say HTML Imports are still the best option (it's the one I chose) as they are very easy to use and work well (Polymer uses them extensively).

Instead you can try RequireJs or implement your own module loader (with XMLHttpRequest).

I don't recommend you to use a ES6 Module Loader polyfill as they are only at experimental stage.

2019 Update

Native implementation of HTML Imports will be removed from Chrome 73 so it is now recommended to use another way (polyfill, third-party library, Javascript module, or native fetch())



来源:https://stackoverflow.com/questions/37345522/if-html-imports-are-dead-deprecated-whats-the-best-way-to-import-your-web-compo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!