Search code examples
javascriptweb-component

Is it bad practice to include external libraries inside web component?


I'm just starting playing with web component. I'm so used to using jQuery, and not sure if I can use some of its functionality inside defining my web component custom Element. Is this considered a bad practice? Is only vanilla Javascript allowed inside? What is the pro and con and for what reason? Thanks.


Solution

  • It's not necessarily a bad practice. Actually it depends on what you intend to do with your Web Component.

    If it's for learning purpose, or if it's to design rapid prototypes, it can be a a good idea.

    If it's to distribute them, maybe it's a bad habit for the reason developed in this post about stacking up different framworks: for example you could face some incompatibilies between different versions of jQuery: the one you use inside your Custom Element, and the developer use in the page that includes your Custom Element.