{"id":13660639,"url":"https://github.com/PolymerLabs/split-element","last_synced_at":"2025-04-24T19:31:35.852Z","repository":{"id":66263335,"uuid":"147957924","full_name":"PolymerLabs/split-element","owner":"PolymerLabs","description":"Lazy loaded LitElements","archived":true,"fork":false,"pushed_at":"2018-09-09T01:15:46.000Z","size":14,"stargazers_count":24,"open_issues_count":1,"forks_count":2,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-11-10T14:42:53.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PolymerLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-09-08T18:06:23.000Z","updated_at":"2023-12-27T03:00:19.000Z","dependencies_parsed_at":"2023-06-12T19:00:50.094Z","dependency_job_id":null,"html_url":"https://github.com/PolymerLabs/split-element","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerLabs%2Fsplit-element","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerLabs%2Fsplit-element/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerLabs%2Fsplit-element/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerLabs%2Fsplit-element/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PolymerLabs","download_url":"https://codeload.github.com/PolymerLabs/split-element/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250693611,"owners_count":21472283,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T05:01:23.996Z","updated_at":"2025-04-24T19:31:30.845Z","avatar_url":"https://github.com/PolymerLabs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# split-element\nLazy-loaded LitElements\n\n## Overview\n\nThis is an experiment in lazy loading element definitions, on demand when the first instance of the element class is created.\n\n## Why?\n\nThis technique might be useful if you don't know ahead of time what elements might appear on a page, like with a content management system where custom elements can appear in the content.\n\n## How does it work?\n\nTo make a SplitElement, you write two element definitions in two modules.\n\nOne is the \"stub\", which defines the eagerly loaded parts of an element: usually the name and the properties, but it could be more. The properties must be defined with the stub so that LitElement can generate `observedAttributes` in time for the `customElements.define()` call.\n\nThe stub also must have a static async `load` method which returns the implementation class.\n\nThe other class is the \"implementation\", which contains everything else.\n\nThe `SplitElement` constructor loads the implementation class and performs an\n\"upgrade\" of the stub to the implementation once it's loaded.\n\n## Example\n\n_Note, the examples use TypeScript_\n\nmy-element.ts:\n```ts\nimport {SplitElement, property} from '../split-element.js';\n\nexport class MyElement extends SplitElement {\n  static async load() {\n    return (await import('./my-element-impl.js')).MyElementImpl;\n  }\n\n  @property() message?: string;\n}\ncustomElements.define('my-element', MyElement);\n```\n\nmy-element-impl.ts:\n```ts\nimport {MyElement} from './my-element.js';\nimport { html } from '../split-element.js';\n\nexport class MyElementImpl extends MyElement {\n  render() {\n    return html`\n      \u003ch1\u003eI've been upgraded\u003c/h1\u003e\n      My message is ${this.message}.\n    `;\n  }\n}\n```\n\n## Status: 🚧 Super experimental 🚧\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPolymerLabs%2Fsplit-element","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPolymerLabs%2Fsplit-element","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPolymerLabs%2Fsplit-element/lists"}