如果 HTML 导入 dead/deprecated 导入 Web 组件 (X-Tag) 模板的最佳方式是什么?

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

我正在开发我的第一个 X-Tag 应用程序,在它的页面上说它适用于 Web 组件 API,例如 'Custom Elements, Shadow DOM, Templates, and HTML Imports'。

我已经开始处理我的模板,但是既然 HTML 导入已被弃用,那么导入它们的最佳选择是什么?

2019更新

HTML 导入的本机实现将从 Chrome 73 中删除,因此现在建议使用本机 或第三方库。

已过时的答案

据我所知,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 仍然可用并受支持。

由于 ES6 Modules 还没有实现,我想说 HTML 导入仍然是最好的选择(这是我选择的),因为它们非常易于使用并且效果很好(Polymer 使用他们广泛)。

相反,您可以尝试 RequireJs 或实现您自己的模块加载器(使用 XMLHttpRequest)。

我不建议您使用 ES6 模块加载器 polyfill,因为它们仅处于实验阶段。