dark Summary web-appcustom-elementelement-attrelement-stateelement-flowglobal-stateimport-elementimport-scriptimport-styleis-visibleis-hiddenrepeat-list trigger-eventlisten-event set-attrset-stateset-timersend-eventhttp-requestrequest-headerrequest-bodyresponse-okresponse-failscripttrigger-element Comparison OperatorsMutation OperatorsData Source
Summary web-appcustom-elementelement-attrelement-stateelement-flowglobal-stateimport-elementimport-scriptimport-styleis-visibleis-hiddenrepeat-list trigger-eventlisten-event set-attrset-stateset-timersend-eventhttp-requestrequest-headerrequest-bodyresponse-okresponse-failscripttrigger-element Comparison OperatorsMutation OperatorsData Source

This element tag is used to import a JavaScript file, it similar with <script type="module"> tag, but it’s only allowed to be used inside <custom-element> tag.

The script tag then will be added in the <head> tag, and will be executed once the Custom element is defined.

The JavaScript file's URL

<custom-element name="my-element">
  <import-script
    from="https://cdn.jsdelivr.net/npm/[email protected]"></import-script>
  <element-flow>
    <trigger-event click="ShowConfettiBtn">
      <script type="module/realm">
        confetti({
          particleCount: 100,
          spread: 70,
          origin: { y: 0.6 }
        });
      </script>
    </trigger-event>
  </element-flow>
  <template>
    <button ref="ShowConfettiBtn">Yay! πŸŽ‰</button>
  </template>
</custom-element>

<my-element></my-element>