Skip to content

WebReflection/custom-libraries

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

customLibraries

Build Status Coverage Status WebReflection status

Social Media Photo by Matteo Maretto on Unsplash

A customElements like registry for user-land libraries.

Based on Some Web Components Hints post idea, but without polluting the customElements registry.

Compatible down to IE10, or even IE9 (with setTimeout polyfill), and every other browser, for a total of 272 bytes once minified and gzipped.

import {define, get, whenDefined} from 'custom-libraries';
// const {define, get, whenDefined} = require('custom-libraries');
// <script src="//unpkg.com/custom-libraries">customLibraries</script>

whenDefined('my-lib').then(myLib => {
  // myLib is defined and passed along
  // get('my-lib') === myLib
});

setTimeout(() => {
  define('my-lib', {any: 'value'});
});

About

A customElements like registry for user-land libraries

Resources

Stars

Watchers

Forks

Packages

No packages published