Search code examples
javascriptdompolymerweb-componentcustom-element

Shared custom element creation performance


The Polymer documentation suggests using a custom element for sharing some static data, like configuration. Something like <app-settings>.

I'm wondering whether it is optimal from performance point of view. Whenever such non-visual element is used it has to be created nonetheless. Wouldn't it be better to simply share the settings in a global variable or in a form of a (AMD/requirejs) module?

The same goes for purely functional tags like <iron-ajax>. If I place many of the inside my custom elements wouldn't it affect performance as opposed to simply using some existing XHR library?


Solution

  • No it's not optimal from a performance point of view.

    Custom Elements are slowly created (and is even slower with polyfill).

    I think a non-visual object gains nothing to be a Custom Element.

    You're right, a simple object would do the job better. Don't get polymerized :-)

    http://jsperf.com/new-vs-create-element/3