-
Notifications
You must be signed in to change notification settings - Fork 2k
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
How to avoid repeated polymer imports when using multiple polymer elements? #4775
Comments
One of the core benefits of HTML imports is that browser de-duplicates them itself (and for Firefox, Safari and Edge polyfill handles this). |
what do you mean de-duplicates? |
I mean this quote from the spec:
That said, browser won't load file imported from the same location twice. |
So does that mean if there was two html import statements with the same url, the first one will be loaded and the second one will be skipped? |
Yes, it does. Hovewer, if you try loading same resource from different locations, e. g. from CDN, such imports won't be de-duplicated and this might result in errors. |
If you have something like this
does that mean the first one will download and insert the heart html into the page DOM, but the second one won't download (re-use from cache), but will insert the heart html into the DOM as well? Also how can loading same resources but from different servers cause an error? |
For some insight on the future of this spec, especially in relation to ES modules, I strongly recommend reading the discussion on HTML modules proposal. |
@TheInvoker if you still have questions about HTML imports, see this article. I also recommend taking a look at ES modules as a future for Polymer 3.0 |
Closing this per above comment. Thanks @web-padawan for the explanation, hopefully it is more clear now @TheInvoker 😄 |
I am new to polymer 2, and it seems, to load a polymer element, you import a html file that has these 3 html imports:
If I then import 5 polymer element html files for 5 different elements, into my main page, I will have 5 times the above 3 imports. How do you avoid all that duplication, and massive import into the DOM?
Am I supposed to remove all the import statements from the 5 files manually? And just keep 1 of each?
https://www.polymer-project.org/2.0/start/quick-tour
Thanks
The text was updated successfully, but these errors were encountered: