{"id":13432428,"url":"https://github.com/typicode/pegasus","last_synced_at":"2025-04-12T23:29:45.303Z","repository":{"id":41287795,"uuid":"20692961","full_name":"typicode/pegasus","owner":"typicode","description":"Load JSON while still loading other scripts","archived":false,"fork":false,"pushed_at":"2017-10-07T15:11:50.000Z","size":136,"stargazers_count":704,"open_issues_count":4,"forks_count":59,"subscribers_count":32,"default_branch":"master","last_synced_at":"2024-10-30T05:57:19.374Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://typicode.github.io/pegasus/","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/typicode.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":"2014-06-10T16:34:31.000Z","updated_at":"2024-08-31T20:51:54.000Z","dependencies_parsed_at":"2022-07-07T11:03:20.658Z","dependency_job_id":null,"html_url":"https://github.com/typicode/pegasus","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Fpegasus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Fpegasus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Fpegasus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Fpegasus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typicode","download_url":"https://codeload.github.com/typicode/pegasus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248646982,"owners_count":21139079,"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-07-31T02:01:11.473Z","updated_at":"2025-04-12T23:29:45.281Z","avatar_url":"https://github.com/typicode.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Pegasus [![](https://badge.fury.io/js/%40typicode%2Fpegasus.svg)](https://www.npmjs.com/package/@typicode/pegasus) ![](https://badge-size.herokuapp.com/typicode/pegasus/master/dist/pegasus.min.js.svg?compression=gzip)\n\n\u003e Pegasus is a tiny lib that lets you load JSON data while loading other scripts.\n\nIf you have a static website, using this technique, you can reduce the time to display data. Works with any JS lib (React, Vue, jQuery, ...).\n\n__Before__\n\n[![](http://i.imgur.com/ves4uIf.png)](http://typicode.github.io/pegasus/)\n\n_JSON (yellow bar) is downloaded several milliseconds after the JS library (orange bar)._\n\n__After (with Pegasus)__\n\n[![](http://i.imgur.com/8sVBtnB.png)](http://typicode.github.io/pegasus/)\n\n_JSON (yellow bar) and the JS library (orange bar) are downloaded at the same time._\n\n## Install\n\n### Embedded (recommended)\n\nTo save a network call, it's recommended to simply paste the following code [pegasus.min.js](https://github.com/typicode/pegasus/blob/master/dist/pegasus.min.js) in your HTML page before other scripts.\n\n### CDN\n\nhttps://unpkg.com/@typicode/pegasus/dist/pegasus.min.js\n\n### npm\n\n```bash\n$ npm install @typicode/pegasus\n```\n\nPlease note that pegasus is available on npm under __[@typicode/pegasus](https://www.npmjs.com/package/@typicode/pegasus)__\n\n## Demo\n\nhttp://typicode.github.io/pegasus\n\n## Benchmark\n\nAverage time to display data on the [demo site](http://typicode.github.io/pegasus).\n\n|             | jQuery only  | jQuery + Pegasus  |\n|:------------|:-------------|:------------------|\n|__EDGE__     | 3000 ms      | 2100 ms           |\n|__3G__       | 860 ms       | 640 ms            |\n|__DSL__      | 270 ms       | 230 ms            |\n\n__Note__: jQuery is used for illustration only, you can use Pegasus with any other Javascript library.\n\n## Usage example\n\n```html\n\u003c!-- Load (or embed) Pegasus before loading any other script --\u003e\n\u003cscript src=\"pegasus.min.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Make your request(s) --\u003e\n\u003cscript\u003e\n  var request = pegasus('http://api.example.com');\n\u003c/script\u003e\n\n\u003c!-- Load your app lib(s) --\u003e\n\u003cscript src=\"lib.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Use .then() method to retrieve data in your app --\u003e\n\u003cscript\u003e\n  request.then(\n    // success handler\n    function(data, xhr) {\n      // do something useful like\n      $('#data').text(JSON.stringify(data));\n    },\n    // error handler (optional)\n    function(data, xhr) {\n      console.error(data, xhr.status)\n    }\n  );\n\u003c/script\u003e\n```\n\nOptionally, you can set a timeout using `pegasus.timeout = milliseconds`\n\n## Support\n\nAll modern browsers and IE9+\n\n## License\n\nMIT - [Typicode](https://github.com/typicode)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypicode%2Fpegasus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypicode%2Fpegasus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypicode%2Fpegasus/lists"}