{"id":27443043,"url":"https://github.com/andrewmd5/hako","last_synced_at":"2025-04-19T19:55:33.244Z","repository":{"id":287864166,"uuid":"965545532","full_name":"andrewmd5/hako","owner":"andrewmd5","description":"An embeddable, lightweight, secure, high-performance JavaScript engine.","archived":false,"fork":false,"pushed_at":"2025-04-16T03:18:47.000Z","size":16498,"stargazers_count":82,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-19T17:57:23.465Z","etag":null,"topics":["javascript","quickjs","quickjs-emscripten","quickjs-ng","quickjs-runtime","webassembly"],"latest_commit_sha":null,"homepage":"https://hakojs.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrewmd5.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-13T12:01:59.000Z","updated_at":"2025-04-19T17:24:01.000Z","dependencies_parsed_at":"2025-04-19T07:50:35.867Z","dependency_job_id":null,"html_url":"https://github.com/andrewmd5/hako","commit_stats":null,"previous_names":["andrewmd5/hako"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewmd5%2Fhako","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewmd5%2Fhako/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewmd5%2Fhako/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewmd5%2Fhako/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewmd5","download_url":"https://codeload.github.com/andrewmd5/hako/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249786131,"owners_count":21325561,"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":["javascript","quickjs","quickjs-emscripten","quickjs-ng","quickjs-runtime","webassembly"],"created_at":"2025-04-15T01:18:40.777Z","updated_at":"2025-04-19T19:55:33.223Z","avatar_url":"https://github.com/andrewmd5.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cp\u003e\n  \u003ca href=\"https://repl.hakojs.com\"\u003e\n    \u003cimg width=\"500\" alt=\"Hako logo\" src=\"./assets/banner.png\" /\u003e\n  \u003c/a\u003e\n  \u003cp\u003eHako (ha-ko) or 箱 means “box” in Japanese. \u003c/p\u003e\n\u003c/p\u003e\n\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.txt)\n\n\nHako is a embeddable, lightweight, secure, high-performance JavaScript engine. It is a fork of PrimJS; Hako has full support for ES2019 and later ESNext features, and offers superior performance and a better development experience when compared to QuickJS. \n\n\u003c/div\u003e\n\n## What makes it secure?\n\nHako compiles down to WebAssembly, a memory-safe, sandboxed execution environment. This means even though Hako is written in C/C++, programs it is embedded in have an extra layer of security from memory corruption attacks. Hako also has a built-in sandboxing mechanism in the form of VMContext which allows you to restrict the capabilities of JavaScript code. \n\nA number of APIs are exposed to limit the amount of memory and 'gas' a script can consume before it is terminated, and development follows an opinionated 'fail-fast' design for bailing out of potentially unstable code that could consume or block I/O. Combining all of these, you can run hundreds of VMs in parallel on a single machine.\n\n![](./assets//hakostress.gif)\n\n\n## What makes it embeddable?\n\nHako does not use Emscripten to compile down to WebAssembly; so long as your language of choice has a WebAssembly runtime, you can embed Hako in it by implementing the necessary imports. You can see an example of embedding Hako in Go [here](https://gist.github.com/andrewmd5/197efb527ef40131c34ca12fd6d0a61e).\n\nIt is also incredibly tiny. The release build is ~800KB.\n\n## What makes it fast?\n\nHako is a fork of [PrimJS](https://github.com/lynx-family/primjs), which in sythentic benchmarks shows performance gains of 28% over QuickJS. Compiling to WebAssembly has no noticable impact on performance as the amazing JIT compilers of JavaScriptCore/Bun, V8/NodeJS, and Wasmtime allow code to run at near-native speeds. You can enable profiling in Hako to see how your code is performing.\n\nHere's a simple string concatenation benchmark comparing Hako to QuickJS and QuickJS-NG:\n\n```javascript\nconst t1 = Date.now()\nlet str = '';\nfor (let i = 0; i \u003c 1000_000; i++) {\n  str += 'a';\n}\nconst t2 = Date.now()\nconsole.log(t2 - t1);\n\n// Results:\n// quickjs-ng: 6854ms\n// quickjs: 112ms\n// hako: 92ms\n```\n\nAs you can see, Hako outperforms both QuickJS and QuickJS-NG in this common operation, with QuickJS-NG being particularly slow at string concatenation.​​​​​​​​​​​​​​​​\n\n## Notice\n\nThis project is still in early access - documentation is a work in progress, and the API/ABI should not be considered stable. If you wish to contribute, please do so by opening an issue or a pull request for further discussion. Your feedback is greatly appreciated.\n\nYou can find the intitial reference implementation of Hako in TypeScript [here](./embedders/ts/README.md).\n\nFor further reading and to get a sense of the roadmap see the initial blog post [here](https://andrewmd5.com/posts/2023-10-01-hako/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewmd5%2Fhako","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewmd5%2Fhako","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewmd5%2Fhako/lists"}