1.0.1 • Published 6 years ago

html-import-js v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

html-import-js

Small library, to import HTML webcomponents inside a JS ES6 file.

Getting started

  1. Add html-import-js to your project:

    npm i -S html-import-js

  2. Require the function

    import { importHref } from 'html-import-js';
  1. Use it to require a HTML compomemt
    importHref ('./bower_components/paper-input/paper-input.html');

Parameters

importHref supports 4 parameters:

href, onload, onerror, optAsync

ParameterDescription
hrefThe relative url of the html file
onloadCallback to notify when an import successfully loaded
onerrorCallback to notify when an import unsuccessfully loaded.
optAsyncTrue if the import should be loaded async, Defaults to false.

Disclaimer

All this code is taken from the Polymer library, as they removed this functionality in the polymer 3 version, this library allows to use it again