0

I want to add videoJS player to polymer app ? How to Adding External JS libraries to Polymer ? Thanks

Swap
  • 237
  • 1
  • 2
  • 11
  • It's a duplicate question of https://stackoverflow.com/questions/22135095/polymer-element-with-javascript-dependencies – Frank R. Jul 21 '17 at 12:58

1 Answers1

2

You need to wrap your JS dependencies in an import file.

  1. Create a new html file call it myVerySpecialLib-import.html.
  2. Add a script tag to that file which points to your library
  3. In the Component in which you want to use your lib import that myVerySpecialLib-import.html file

That's it! Now, you can use your library in your component.

Pascal L.
  • 1,261
  • 9
  • 21
  • I left this part of your edit out because its simply just not true the only way to get a external library in your webcomponent working is to put it in an import file! If you put your script tag directly in your component you can´t be sure its aleady loaded since polymer does not wait for it. – Pascal L. Jul 20 '17 at 08:32
  • It's something I should keep in mind. It would be thankful if you happened to have a link reference. – Frank R. Jul 20 '17 at 14:54
  • Hi sry can´t give you a reference. I found this out the hardway. I wrote a WebComponent which wrapps a angular1 app (stupid idea i know but it works). If i add all the dependencies as a script tag it does not work, but if i create import files it does. – Pascal L. Jul 20 '17 at 15:31