Vulcanize produces repeated scripts

96 Views Asked by At

I have created two Polymer custom elements. Both of them uses moment.js. So I have referenced it in both the elements, like: <script src="../../bower_components/moment/min/moment.min.js"></script> I use vulcanize to produce a single import file element.html. The issue is that the content of moment.js appears twice in the vulcanized file. Is this correct? Is there a way to avoid it?

1

There are 1 best solutions below

1
Scarygami On BEST ANSWER

You can create a moment-import.html in which you include the script, and then import that file in both your elements.

HTML imports are only loaded once across all elements and vulcanize will de-duplicate them for you.