0

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?

Abhijeet Kumar
  • 133
  • 1
  • 6

1 Answers1

2

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.

Scarygami
  • 15,009
  • 2
  • 35
  • 24
  • 2
    In fact: there is such a thing already ... https://github.com/bendavis78/moment-element :) – ankon Mar 24 '16 at 09:17