{"id":18013020,"url":"https://github.com/hackwaly/define.js","last_synced_at":"2025-08-22T23:08:09.577Z","repository":{"id":146286988,"uuid":"10660801","full_name":"hackwaly/define.js","owner":"hackwaly","description":"yet another `amd` loader that support `sync' mode specially.","archived":false,"fork":false,"pushed_at":"2013-06-25T10:53:32.000Z","size":265,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T23:49:39.730Z","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/hackwaly.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":"2013-06-13T07:11:33.000Z","updated_at":"2016-06-03T02:00:52.000Z","dependencies_parsed_at":"2023-03-23T22:33:40.909Z","dependency_job_id":null,"html_url":"https://github.com/hackwaly/define.js","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/hackwaly%2Fdefine.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackwaly%2Fdefine.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackwaly%2Fdefine.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackwaly%2Fdefine.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackwaly","download_url":"https://codeload.github.com/hackwaly/define.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190242,"owners_count":20898705,"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-10-30T03:19:40.339Z","updated_at":"2025-04-04T14:20:37.554Z","avatar_url":"https://github.com/hackwaly.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"define.js\n=========\nyet another `amd` loader that support `sync' mode specially.\n\n# Build \u0026 Optimze\n\nthe difference from other `amd` loader, such as \"requirejs\" and so on:\n\n* not just concat modules. the result you won't see `define` and `require`, include the define closure of almost all module. the result code will in a big closure.\n* you can build a standalone main module script by giving the main module id.\n* you can build a main module script with several lazy load modules as your config. the build-chain will analyze the \"async require\" (`require([],callback)`) and implicit dependencies(who are in main module, who are in other lazy module, and who are in the up closure). then process it smartly. the lazy module use `eval` to load in the up module's closure. just like \"google maps\" do.\n\n# How To Use\n\n* use `data-base` attribute to set baseUrl. if's bootstrap path by default.\n* use `data-sync` attribute to set sync mode. it's `\"false\"` by default.\n* use `data-main` attribute to set main module id. it's required.\n\nin `sync` mode, you can do this.\n```html\n\u003cscript src=\"define.js\" data-main=\"your_library/your_api\" data-sync=\"true\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    // you api is ready for use.\n    my_api.alert('hello define.js');\n\u003c/script\u003e\n```\nyour api\n```javascript\nvar my_api;\ndefine(function (require){\n    var alert = require('your_library/your_alert');\n    my_api = {};\n    my_api.alert = alert;\n});\n```\nyour alert\n```javascript\ndefine(function (require, exports){\n    exports.alert = function (msg){\n        alert(msg);\n    };\n});\n```\nso, you can simply replace the script tag to switch release version and dev version.\n\nyou did't need write `require([...], function (){ ... })` in your html page.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackwaly%2Fdefine.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackwaly%2Fdefine.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackwaly%2Fdefine.js/lists"}