{"id":16296634,"url":"https://github.com/f1lt3r/hybrids-dynamic-load","last_synced_at":"2026-05-04T05:33:32.358Z","repository":{"id":145878489,"uuid":"244266876","full_name":"F1LT3R/hybrids-dynamic-load","owner":"F1LT3R","description":"Example of an unbundled Hybrids app with dynamic imports.","archived":false,"fork":false,"pushed_at":"2020-03-02T03:28:23.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T10:09:54.982Z","etag":null,"topics":["dynamic-loading","hybrids","javascript","javascript-modules","web-components"],"latest_commit_sha":null,"homepage":"https://f1lt3r.github.io/hybrids-dynamic-load/ ","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/F1LT3R.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-02T02:57:41.000Z","updated_at":"2020-03-03T01:01:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"cb2bd8bf-268e-4929-945f-822e4c403dca","html_url":"https://github.com/F1LT3R/hybrids-dynamic-load","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/F1LT3R%2Fhybrids-dynamic-load","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fhybrids-dynamic-load/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fhybrids-dynamic-load/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fhybrids-dynamic-load/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/F1LT3R","download_url":"https://codeload.github.com/F1LT3R/hybrids-dynamic-load/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248048739,"owners_count":21039088,"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":["dynamic-loading","hybrids","javascript","javascript-modules","web-components"],"created_at":"2024-10-10T20:23:25.996Z","updated_at":"2026-05-04T05:33:32.291Z","avatar_url":"https://github.com/F1LT3R.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hybrids Dynamic Load\n\nThis codebase is an example of an unbundled [Hybrids](https://hybrids.js.org/) app with [dynamic module imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import).\n\nPlease visit the GitHub Pages to see this code in action: [https://f1lt3r.github.io/hybrids-dynamic-load/](https://f1lt3r.github.io/hybrids-dynamic-load/)\n\n## The Page Module\n\n```js\nconst name = 'welcome-page'\n\ndefine(name, {\n  render: () =\u003e\n    html`\n      \u003cdiv\u003e\n        \u003ch2\u003eWelcome Page\u003c/h2\u003e\n        \u003cp\u003eThis Welcome page was dynamically loaded.\u003c/p\u003e\n      \u003c/div\u003e\n    `,\n})\n\n// The name is exported for use as the custom element name\nexport default name\n```\n\n## The Main App Module\n\n```js\n// This dynamic load function fetches the module at run time\nconst load = async (host, event) =\u003e {\n    // Get the module URL from a DOM attribute\n    const pageUrl = event.target.getAttribute('page')\n\n    // Import the page and reference default (the custom element name)\n    const pageName = (await import(pageUrl)).default\n\n    // Set the page element on the Hybrid host\n    // This triggers a re-render\n    host.pageLoaded = `\u003c${pageName}\u003e\u003c/${pageName}\u003e`\n}\n\n// The main Hybrid component that drives the App \nconst HybridsApp = {\n    appName: 'Welcome to Hybrids!',\n\n    // Set default placeholder content\n    pageLoaded: '\u003cspan\u003eNo page loaded, yet.\u003c/span\u003e',\n\n    // Render the pageLoaded string\n    page: ({ pageLoaded }) =\u003e pageLoaded,\n\n    render: ({ appName, page }) =\u003e html`\n      \u003cdiv\u003e\n        \u003ch1\u003e${appName}\u003c/h1\u003e\n\n        \u003cp\u003eExample of an unbundled Hybrids app with dynamic imports.\u003c/p\u003e\n\n        \u003cdiv\u003e\n          \u003cbutton onclick=\"${load}\" page=\"./pages/Welcome.mjs\"\u003e\n            Welcome Page\n          \u003c/button\u003e\n          \u003cbutton onclick=\"${load}\" page=\"./pages/Other.mjs\"\u003e\n            Other Page\n          \u003c/button\u003e\n        \u003c/div\u003e\n\n        \u003chr /\u003e\n\n        \u003c!-- Render the page using Hybrids innerHTML feature --\u003e\n        \u003carticle innerHTML=\"${page}\"\u003e\u003c/article\u003e\n      \u003c/div\u003e\n    `,\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff1lt3r%2Fhybrids-dynamic-load","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff1lt3r%2Fhybrids-dynamic-load","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff1lt3r%2Fhybrids-dynamic-load/lists"}