{"id":16906663,"url":"https://github.com/rsms/browser-require","last_synced_at":"2025-09-10T01:39:08.769Z","repository":{"id":1023745,"uuid":"851686","full_name":"rsms/browser-require","owner":"rsms","description":"CommonJS module require() for web browsers","archived":false,"fork":false,"pushed_at":"2010-08-21T14:35:25.000Z","size":103,"stargazers_count":26,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-28T03:09:13.152Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rsms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-08-20T17:38:08.000Z","updated_at":"2024-04-06T01:53:37.000Z","dependencies_parsed_at":"2022-07-15T06:16:02.883Z","dependency_job_id":null,"html_url":"https://github.com/rsms/browser-require","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rsms/browser-require","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fbrowser-require","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fbrowser-require/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fbrowser-require/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fbrowser-require/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsms","download_url":"https://codeload.github.com/rsms/browser-require/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fbrowser-require/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274396805,"owners_count":25277398,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-13T18:43:50.932Z","updated_at":"2025-09-10T01:39:08.705Z","avatar_url":"https://github.com/rsms.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# browser-require\n\n[CommonJS module](http://wiki.commonjs.org/wiki/Modules) system for web browsers.\n\n## Usage \u0026 examples\n\nFirt off, you need to load `require.js` -- i.e. `\u003cscript src=\"require.js\"\u003e\u003c/script\u003e` -- then...\n\n### Embedded module definitions\n\n    \u003cscript\u003e\n    require.define('foo', function(require, module, exports){\n      exports.hello = \"hello from the foo module\";\n    });\n    var foo = require('foo');\n    alert(foo.hello);\n    \u003c/script\u003e\n\n\u003e Pssst! You can find more examples in the `example` directory.\n\n### Loading (and defining) remote modules\n\nfoo.js\n\n    exports.hello = \"hello from the foo module\";\n\nindex.html\n\n    \u003cscript\u003e\n    require.load('foo.js', function (err) {\n      if (err) throw err;\n      var foo = require('foo');\n      alert(foo.hello);\n    });\n    \u003c/script\u003e\n\n#### Multiple remote modules can be loaded in parallel\n\n    \u003cscript\u003e\n    require.load([\n      'foo.js',\n      'bar/baz.js',\n      {id: 'user-agent', url:'http://internets.com/lib/ua.js'}\n      {'http://moset.com/strkit/formatting.js'}\n    ], function (err) {\n      if (err) throw err;\n      var foo = require('foo'),\n          baz = require('bar/baz'),\n          userAgent = require('user-agent'),\n          formatting = require('strkit/formatting');\n      alert(foo.hello);\n      // ...\n    });\n    \u003c/script\u003e\n\n#### Remote modules can also be loaded synchronously\n\n\u003e **Warning:** synchronous loading will block until they complete. This should only be used when loading files from reliable/fast sources (like localhost or file://).\n\n    \u003cscript\u003e\n    require.load(['foo.js', 'bar/baz.js']);\n    var foo = require('foo'),\n        baz = require('bar/baz');\n    alert(foo.hello);\n    // ...\n    \u003c/script\u003e\n\n## API\n\n### require(String id[, String parentId]) -\u003e [object module-exports]\n\nImport module with identifier `id`.\n\n- `id` can be a relative path like \"./foo\" or \"../../foo\", but only makes sense when `require` is called from within another module or `parentId` is provided.\n\n### require.define(String id, [String uri,] Function block(require, module, exports){...})\n\nDefine a module, adding it to the list of available modules. The `block` function will be called (once) at the first `require` of the module (i.e. the actual execution is delayed/lazy).\n\nIf the `uri` argument is given, the resulting module will have a read-only `uri` property referring to that value. This is optional per the CommonJS spec.\n\nYou module (the code inside `block`) should export its API through the `exports` object like so:\n\n    require.define('foo', function(require, module, exports){\n      exports.hello = \"hello from foo\";\n    });\n    ...\n    var foo = require('foo');\n    puts(foo.hello); // -\u003e \"hello from foo\"\n\nIt's also possible to *set* the `exports` object:\n\n    require.define('foo', function(require, module, exports){\n      exports = module.exports = function() {\n        return \"hello from foo function\"\n      }\n      exports.hello = \"hello from foo\";\n    });\n    ...\n    var foo = require('foo');\n    puts(foo()); // -\u003e \"hello from foo function\"\n    puts(foo.hello); // -\u003e \"hello from foo\"\n\n\n### require.main -\u003e [object module]\n\nThe top level module object (read-only). This modules' `exports` member normally refers to `window`.\n\n    require.main === window === true\n\n\n### require.load(Object spec|Array specs|String url[, Function callback(Error err)])\n\nLoad and define a remotely located module.\n\nA `spec` object should have at least one of two properties:\n\n    { url: String  // URL or path to the module resource\n    , id:  String  // Module identifier\n    }\n\n- If no `url` is given, `url` is created from `id` by appending \".js\"\n- If no `id` is given, `id` is deduced from `url` by stripping anything else than path and also stripping any filename extension.\n\nYou can also pass an array of `spec` objects or strings. Passing a string is equivalent to passing a `spec` object like this: `{url: url}`\n\n**Note:** If no `callback` is passed, **loading will be synchronous**.\n\n\n### [object module]\n\nA module object have the following members:\n\n- `exports` -- an object representing the API\n- `id` -- Identifier (read-only)\n\nOptional/not-always-there members:\n\n- `uri` -- URI which might be a URL denoting the module source\n\n\n## MIT license\n\nCopyright (c) 2010 Rasmus Andersson \u003chttp://hunch.se/\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsms%2Fbrowser-require","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsms%2Fbrowser-require","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsms%2Fbrowser-require/lists"}