How can you / is it possible to avoid making server request per web component?
Background
So, with javascript a lot of people are now using the so called AMD model of module loading, in which all the modules are separate javascript files and get included as required. eg.
- main.js
-- module1/mod1.js
-- module2/mod2.js
-- module3/mod3.js
This results in multiple requests to the server, one for each javascript file. This is considered harmful to app performance, particularly in mobile as the number of javascript modules increases.
As a result tools such as require.js provide a compiler that will automatically trace dependencies and generate a single javascript file with all the modules in it; effectively reducing the request overhead to a single file (typically app-min.js).
Web components
Every web component sits in an external file island and gets imported using a link tag in the header:
<link rel="import" href="elements/image-gallery.html">
<link rel="import" href="elements/social-media.html">
<link rel="import" href="elements/pinmap.html">
<link rel="import" href="elements/nav-menu.html">
If you're using polymer, you can use the vulcanize tool to combine polymer components (http://www.polymer-project.org/articles/concatenating-web-components.html), but that's because (as I understand it) polymer is a javascript framework that loads web components dynamically from "polymer-element" tags.
Is there an equivalent way of doing this with 'vanilla' web components that do not rely on a frame work such as x-tag or polymer?