在哪里放置 Polymer/Web 组件的 LINK 语句

Where to place LINK statement for Polymer/ web components

我是组件新手,正在尝试将一些组件实现到新主题中。我的问题是关于最佳实践以及最好在什么范围内包含这些文件。例如,将它们全部加载到索引页中有什么好处,还是应该在使用时链接并包含它们?如果我动态加载它们,它们是否有可能发生冲突?

我希望这是有道理的。提前感谢您的帮助。

webcomponents.org这里有明确的答案:

Normal HTML Imports are eager, meaning that they are loaded and evaluated in order first, before any code that follows. You can get a large performance improvement by lazily loading code at runtime, so that you only load the minimal amount of code needed to display the current view. This is a key piece of the PRPL pattern.

To do lazy loading of your HTML you can use javascript APIs like Polymer.importHref. What this repo adds to that is a declarative way to describe the resources that you will import lazily, and a method for loading them. Because this kind of lazy import is declarative, the polymer analyzer, polymer linter, and polymer bundler all understand them, giving you accurate lint warnings and sharded bundling without any configuration needed, just your source code. For remaining information go through : https://www.webcomponents.org/element/Polymer/lazy-imports