{"id":18455622,"url":"https://github.com/memowe/script-importer","last_synced_at":"2025-04-22T17:13:12.109Z","repository":{"id":56311472,"uuid":"311323831","full_name":"memowe/script-importer","owner":"memowe","description":"Load non-module libraries in a clean module-like fashion.","archived":false,"fork":false,"pushed_at":"2021-03-17T15:22:19.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-25T05:09:55.406Z","etag":null,"topics":["dependency","ecmascript","javascript","module","script-element"],"latest_commit_sha":null,"homepage":"","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/memowe.png","metadata":{"files":{"readme":"README.md","changelog":"Changes.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-09T11:57:44.000Z","updated_at":"2020-12-11T11:41:27.000Z","dependencies_parsed_at":"2022-08-15T16:30:56.741Z","dependency_job_id":null,"html_url":"https://github.com/memowe/script-importer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memowe%2Fscript-importer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memowe%2Fscript-importer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memowe%2Fscript-importer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memowe%2Fscript-importer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/memowe","download_url":"https://codeload.github.com/memowe/script-importer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239143853,"owners_count":19589084,"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":["dependency","ecmascript","javascript","module","script-element"],"created_at":"2024-11-06T08:08:35.611Z","updated_at":"2025-02-16T14:45:11.202Z","avatar_url":"https://github.com/memowe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ScriptImporter\n\n**Load non-module libraries in a clean module-like fashion.**\n\n## Usage\n\nWhen used in the browser, this module needs to be imported as a `module`, for example:\n\n```html\n\u003cscript type=\"module\" src=\"./script-importer.js\"\u003e\n```\n\nThe class can take a URL prefix string (e. g. your favourite CDN) and import single or multiple modules at a time. Its `load` method returns a promise:\n\n```javascript\n// Initialize with jsdelivr\nconst si = new ScriptImporter('https://cdn.jsdelivr.net/npm/');\n\n// Single library usage\nsi.load('foo-library').then(() =\u003e {\n    workWithFoo();\n});\n```\n\nMultiple library usage: just append arguments (loaded in parallel)\n\n```javascript\nsi.load('foo-library', 'dist/bar-library.min.js').then(() =\u003e {\n    // Everything is loaded\n    workWithFoo();\n    workWithBar();\n});\n```\n\nDependencies, that need to be loaded sequentially, can be connected via an array. In this example, bar-special is loaded when bar-base has finished loading:\n\n```javascript\nsi.load('foo-library', ['bar-base', 'bar-special']).then(() =\u003e {\n    // Everything is loaded\n    workWithFoo();\n    workWithBarSpecial();\n});\n```\n\nOutside of loading sequences, load is tolerant to failures and reports them together with loaded classes in a combined results object:\n\n```javascript\n{\n    loaded: [urls],\n    failed: [urls]\n}\n```\n\nSo loading errors can be reported easily:\n\n```javascript\nsi.load(...).then(results =\u003e {\n    results.failed.forEach(lib =\u003e console.log(\"Couldn't load \" + lib));\n    ...\n});\n```\n\nSee [example.html][example] for a markdown example.\n\n## Load via CDN\n\nThis module is accessible via GitHub Pages and jsDelivr:\n\n- [GitHub Pages][ghp] (only the latest version on `main` branch)\n- jsDelivr CDN (cached and auto-minified): [/gh/memowe/script-importer@**tag**/script-importer.js][jsd]\n    - [List of tags][sitags]\n    - auto-minified: [.../script-importer.min.js][jsdmin]\n    - It [should][jsdgh] be possible to use it with `@latest` or even without that `@`. Sometimes it [doesn't][jsdbug].\n\n## Contributors\n\n- [\\@devolt5][devolt5]\n- [\\@memowe][mgh]\n\nOriginal author: [\\@memowe][mgh]\n\n## License\n\nCopyright (c) [Mirko Westermeier][mirko] ([\\@memowe][mgh], [mirko@westermeier.de][mmail])\n\nReleased under the MIT (X11) license. See [LICENSE][mit] for details.\n\n[example]: example.html\n[ghp]: https://memowe.github.io/script-importer/script-importer.js\n[jsd]: https://cdn.jsdelivr.net/gh/memowe/script-importer@v0.3/script-importer.js\n[sitags]: https://github.com/memowe/script-importer/tags\n[jsdmin]: https://cdn.jsdelivr.net/gh/memowe/script-importer@v0.3/script-importer.min.js\n[jsdgh]: https://www.jsdelivr.com/?docs=gh\n[jsdbug]: https://github.com/jsdelivr/jsdelivr/issues/18216\n[devolt5]: https://github.com/devolt5\n[mgh]: https://github.com/memowe\n[mirko]: https://mirko.westermeier.de\n[mmail]: mailto:mirko@westermeier.de\n[mit]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemowe%2Fscript-importer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmemowe%2Fscript-importer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemowe%2Fscript-importer/lists"}