{"id":13726812,"url":"https://github.com/binast/binjs-ref","last_synced_at":"2025-05-16T11:04:37.498Z","repository":{"id":52023000,"uuid":"90141336","full_name":"binast/binjs-ref","owner":"binast","description":"Reference implementation for the JavaScript Binary AST format","archived":false,"fork":false,"pushed_at":"2021-05-08T05:30:11.000Z","size":61404,"stargazers_count":435,"open_issues_count":112,"forks_count":33,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-13T05:26:42.577Z","etag":null,"topics":["binary","ecmascript","javascript","parsing","performance","prototype"],"latest_commit_sha":null,"homepage":"https://binast.github.io/binjs-ref/binjs/index.html","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binast.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-05-03T11:25:08.000Z","updated_at":"2025-04-22T07:06:12.000Z","dependencies_parsed_at":"2022-08-29T19:21:25.222Z","dependency_job_id":null,"html_url":"https://github.com/binast/binjs-ref","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binast%2Fbinjs-ref","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binast%2Fbinjs-ref/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binast%2Fbinjs-ref/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binast%2Fbinjs-ref/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binast","download_url":"https://codeload.github.com/binast/binjs-ref/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518384,"owners_count":22084374,"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":["binary","ecmascript","javascript","parsing","performance","prototype"],"created_at":"2024-08-03T01:03:24.268Z","updated_at":"2025-05-16T11:04:32.486Z","avatar_url":"https://github.com/binast.png","language":"Rust","readme":"[![Travis Status](https://travis-ci.org/binast/binjs-ref.svg?branch=master)](https://travis-ci.org/binast/binjs-ref)\n\n# About the JavaScript Binary AST\n\n\nAs websites become more sophisticated, the amount of JavaScript source code keeps\nincreasing. While depending upon a large JavaScript codebase won't prevent a website\nfrom working, it will cause websites to\nstart slowly – often [unacceptably slow](https://medium.com/reloading/javascript-start-up-performance-69200f43b201).\nThis is due to two bottlenecks: parsing and bytecode compiling JavaScript.\nUnfortunately, browsers have pretty much\nreached efficiency peak for both operations.\n\nWe (Mozilla, Bloomberg, Facebook, CloudFlare) are currently working on a\ndomain-specific encoding for JavaScript, called \"BinAST\" (short for\n\"JavaScript Binary AST\"). The JavaScript Binary AST is designed to\nbreak the bottleneck. Current\nadvanced prototypes already show JS [parsing improvements of 30%-50%](https://gist.github.com/Yoric/1d41cdf3715815d39032f0dbce31ed42) on\nall the most common frameworks, just by changing the format,\nand we believe that we can increase\nthis improvement much further. The encoding can be built as part of a\nwebdev toolchain, or injected by a\nproxy or CDN, hence automatically improving the performance of end users\nwithout change to the original website.\n\nThis encoding is currently in the JavaScript TC39 standardization process [3].\nIt can be used alongside existing compression techniques (gzip, brotli, etc.)\n\n## Testing it\n\n1. Install dependencies (you will need `npm`, `rustup`)\n```\nnpm install\nrustup install nightly\nrustup default nightly\n```\n2. Pull the code.\n```\ngit clone https://github.com/binast/binjs-ref\n```\n3. Compress/decompress.\n```\ncargo run --bin binjs_encode -- --help\ncargo run --bin binjs_decode -- --help\n```\n**Note** The JS parser may choke on very large JS source files. If so, you'll need to set the environment variable `NODE_MAX_OLD_SPACE_SIZE=xxxx`. This will instruct the Node-based parser to allocate more memory. The default value is 2048 (Mb). This is equivalent to passing `--max_old_space_size` to the Node process.\n\n4. Dump tree structure.\n```\ncargo run --bin binjs_dump -- --help\n```\n**Note** `binjs_dump` supports only `multipart` format.\n\n## Compatibility with JavaScript source code\n\nPreserved:\n- semantics of well-formed programs;\n- variable and function names.\n\nNot preserved:\n- actual semantics of syntax errors;\n- source code positions;\n- formatting (including whitespaces and semicolumns);\n- comments (including source maps).\n\n## Expected benefits\n\n\nThe Binary AST format is designed to be generally faster to parse than JS source,\nthanks to a syntax that requires no backtracking, strings that do not need\ninterning more than once, etc.\n\nThe Binary AST format is designed so that the VM can start parsing the file\nas soon as the first few bytes are received (streaming parsing) and can\nstart compiling the file to bytecode soon after that (streaming bytecode compilation).\n\nFurthermore, parsing a JS source is specified for a specific encoding, which\nmeans that many encodings need to be transcoded before they can be parsed\n(or, at best, while parsing), which slows down parsing. As BinAST is\na binary format, it does not need any form of transcoding.\n\nFinally, most modern JavaScript VMs support a form of lazy parsing, which\nperforms faster parsing without most memory allocations. The BinAST format is\ndesigned to make lazy parsing more efficient, if required,\nby letting parsers jump over (functions) in a single operation.\n\n# Specifications\n\n- The semantics are specified [here](https://binast.github.io/ecmascript-binary-ast/).\n- The binary format is specified [here](https://binast.github.io/binjs-ref/binjs_io/multipart/).\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinast%2Fbinjs-ref","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinast%2Fbinjs-ref","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinast%2Fbinjs-ref/lists"}