Given only user elements, you can call document.registerElement whenever you want. From this point of view, you can dynamically load the script using any known method and have dynamic user elements.
Now, regarding the import of HTML:
You could just use JavaScript to write the HTML import, and then add the code to the page
Yes, thatβs the main idea.
Recent versions of HTML Imports polyfill support dynamic link tags. IOW you can do
var link = document.createElement('link'); link.setAttribute('rel', 'import'); link.setAttribute('href', some_href); link.onload = function() {
In addition, Polymer has improved support for this function, namely the imperative api, like this:
Polymer.import([some_href], function() { // called back when some_href is completely loaded, including // external CSS from templates });
The first argument is an array, so you can request multiple hrefs.
Scott miles
source share