MCPcopy Index your code
hub / github.com/WebReflection/uce-loader

github.com/WebReflection/uce-loader @v2.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.0 ↗ · + Follow
19 symbols 38 edges 12 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

µce-loader

Social Media Photo by Guillaume Bolduc on Unsplash

A minimalistic, framework agnostic, lazy Custom Elements loader.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <script type="module">
  // <script src="https://github.com/WebReflection/uce-loader/raw/v2.0.0/unpkg.com/uce-loader"> or ...
  import loader from '//unpkg.com/uce-loader?module';

  // will load every custom elements via the path
  loader({
    // by default it's document
    container: document.body,
    // invoked per each new custom-element name found
    on(newTag) {
      const js = document.createElement('script');
      js.src = `js/components/${newTag}.js`;
      document.head.appendChild(js);
    }
  });
  // js/components/compo-nent.js
  // js/components/what-ever.js
  // which will bring in also
  // js/components/whatever-else.js
  </script>
</head>
<body>
  <compo-nent></compo-nent>
  <hr>
  <what-ever></what-ever>
</body>
</html>

If loader({container: document, on(tagName){}}) API is too simplified, feel free to check lazytag out.

About ShadowDOM

If your components use attachShadow and internally use custom elements that should be lazy loaded, be sure the shadowRoot is observed.

const shadowRoot = this.attachShadow({mode: any});
loader({
    container: shadowRoot,
    on(newTag) {
      // ... load components
    }
  });

V2 vs V1

Current version of this module does not invoke the .on(...) method if the element is already registered as Custom Element.

In V1 any tag name would've passed through the loader instead.

Core symbols most depended-on inside this repo

a
called by 2
min.js
s
called by 2
es.js
crawl
called by 2
index.js
crawl
called by 2
esm/index.js
crawl
called by 2
cjs/index.js
o
called by 1
min.js
r
called by 1
es.js
load
called by 1
index.js

Shape

Function 10
Class 6
Method 3

Languages

TypeScript100%

Modules by API surface

test/whatever-else.js3 symbols
test/what-ever.js3 symbols
test/compo-nent.js3 symbols
min.js2 symbols
index.js2 symbols
esm/index.js2 symbols
es.js2 symbols
cjs/index.js2 symbols

For agents

$ claude mcp add uce-loader \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page