{"id":13658795,"url":"https://github.com/feross/load-script2","last_synced_at":"2025-09-13T01:32:25.593Z","repository":{"id":53169549,"uuid":"82656052","full_name":"feross/load-script2","owner":"feross","description":"Dynamic script loading for modern browsers","archived":false,"fork":false,"pushed_at":"2021-04-02T20:46:26.000Z","size":28,"stargazers_count":47,"open_issues_count":1,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-03T02:53:09.682Z","etag":null,"topics":["browser","javascript","script","script-loader"],"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/feross.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}},"created_at":"2017-02-21T08:38:53.000Z","updated_at":"2024-09-25T09:11:08.000Z","dependencies_parsed_at":"2022-08-13T02:20:29.921Z","dependency_job_id":null,"html_url":"https://github.com/feross/load-script2","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fload-script2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fload-script2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fload-script2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fload-script2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feross","download_url":"https://codeload.github.com/feross/load-script2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232808054,"owners_count":18579532,"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":["browser","javascript","script","script-loader"],"created_at":"2024-08-02T05:01:02.707Z","updated_at":"2025-01-07T01:21:53.688Z","avatar_url":"https://github.com/feross.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# load-script2 [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]\n\n[travis-image]: https://img.shields.io/travis/feross/load-script2/master.svg\n[travis-url]: https://travis-ci.org/feross/load-script2\n[npm-image]: https://img.shields.io/npm/v/load-script2.svg\n[npm-url]: https://npmjs.org/package/load-script2\n[downloads-image]: https://img.shields.io/npm/dm/load-script2.svg\n[downloads-url]: https://npmjs.org/package/load-script2\n[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n[standard-url]: https://standardjs.com\n\n### Dynamic script loading for modern browsers\n\nWorks in the browser with [browserify](http://browserify.org/)!\n\n## install\n\n```\nnpm install load-script2\n```\n\nThis package works in the browser with [browserify](https://browserify.org). If you do not use a bundler, you can use the [standalone script](https://bundle.run/load-script2) directly in a `\u003cscript\u003e` tag.\n\n## usage\n\n```js\nconst loadScript = require('load-script2')\n\nconst script = await loadScript('foo.js')\nconsole.log(script.src);// Prints 'foo'.js'\n```\n\n## differences to [`load-script`](https://www.npmjs.com/package/load-script)\n\n`load-script2` does not support legacy browsers like IE8 because these browsers\ndo not have standards-based DOM APIs. `load-script2` also removes many esoteric\noptions, which aren't needed most of the time and adds **promises support**.\n\nThe size of `load-script2` is 509 bytes, compared to 655 bytes for `load-script` (minified\nand gzipped).\n\n## API\n\n### `promise = loadScript(src, [attrs], [parentNode])`\n\nAppend a `\u003cscript\u003e` node with the given `src` URL to the `\u003chead\u003e` element in the DOM.\n\n#### `src`\n\nAny url that you would like to load.  May be absolute or relative.\n\n#### `attrs` (optional)\n\nAn object that contains HTML attributes to set on the `\u003cscript\u003e` tag. For\nexample, the value `{ id: 'hi' }` would set the attribute `id=\"hi\"` on the\n`\u003cscript\u003e` tag before it is injected.\n\n#### `parentNode` (optional)\n\nThe HTML node to which the `\u003cscript\u003e` tag will be appended. If not specified,\ndefaults to the `\u003chead\u003e` tag.\n\n#### `promise`\n\nReturns a promise which resolves to the `script` node that was appended to the\nDOM, or rejects with `err` if any occurred.\n\n## license\n\nMIT. Copyright (c) [Feross Aboukhadijeh](https://feross.org).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeross%2Fload-script2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeross%2Fload-script2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeross%2Fload-script2/lists"}