{"id":13879729,"url":"https://github.com/jhawthorn/execjs-fastnode","last_synced_at":"2025-11-11T18:32:00.448Z","repository":{"id":56845157,"uuid":"70775559","full_name":"jhawthorn/execjs-fastnode","owner":"jhawthorn","description":":zap: A faster Node.JS integration for Ruby/Rails ExecJS","archived":false,"fork":false,"pushed_at":"2019-08-16T19:48:13.000Z","size":95,"stargazers_count":51,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T16:11:06.491Z","etag":null,"topics":["execjs","javascript","rails","ruby","sprockets"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/jhawthorn.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":"2016-10-13T06:23:46.000Z","updated_at":"2024-01-24T13:18:56.000Z","dependencies_parsed_at":"2022-09-17T11:02:20.205Z","dependency_job_id":null,"html_url":"https://github.com/jhawthorn/execjs-fastnode","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhawthorn%2Fexecjs-fastnode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhawthorn%2Fexecjs-fastnode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhawthorn%2Fexecjs-fastnode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhawthorn%2Fexecjs-fastnode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhawthorn","download_url":"https://codeload.github.com/jhawthorn/execjs-fastnode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837274,"owners_count":21169373,"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":["execjs","javascript","rails","ruby","sprockets"],"created_at":"2024-08-06T08:02:30.553Z","updated_at":"2025-11-11T18:31:55.422Z","avatar_url":"https://github.com/jhawthorn.png","language":"Ruby","readme":"# ExecJS FastNode\n\n## What's this?\n\nAn alternative implementation of ExecJS's Node.js integration. This aims to speed up sprockets compilation without needing to embed a javascript interpreter inside of ruby like [therubyracer](cowboyd/therubyracer).\n\n## How much faster is it?\n\nMuch.\n\n```\n$ rake bench\n...\n                    user       system     total      real\nNode.js (V8) fast   0.000000   0.000000   0.000000   (0.069723)\ntherubyracer (V8)   0.020000   0.000000   0.020000   (0.018010)\nNode.js (V8)        0.000000   0.010000   1.470000   (1.487579)\n```\n\nOkay, so it's not as fast as `therubyracer`, but it's 20x faster than the standard ExecJS Node.js implementation.\n\nThe benchmark measures the time to compile the javascript CoffeeScript compiler and then eval a small snippet 10 times.\n\n## How?\n\nThe existing ExecJS runtime has to run a new Node.js process each time any JS is to be run. This means that if you are loading up the CoffeeScript compiler in order to compile some sprockets assets, it needs to reload the node executable and the entire coffeescript compiler for each file it is compiling.\n\nThis implementation avoids this by starting a persistently running Node.js process connected through a UNIX socket. Isolation between different ExecJS contexts is achieved through Node's [vm.Script](https://nodejs.org/api/vm.html).\n\n| ExecJS FastNode | Standard ExecJS Node |\n| --- | --- |\n| ![](docs/example_new.png) | ![](docs/example_old.png) |\n\n## Is this production ready?\n\nMaybe? It needs more testing to be labeled as such. If you encounter any troubles please [file an issue](https://github.com/jhawthorn/execjs-fastnode/issues/new).\n\nCurrently minimal effort is made to handle catastrophic errors: Node.js crashing, running out of memory, being killed.\n\nIt's probably fine for development.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'execjs-fastnode'\n```\n\nAnd then `bundle install`. You know the drill.\n\nYou can verify that this runtime is being autodetected and used by checking `ExecJS.runtime` in a console.\n\nYou can force a certain runtime to be used using `EXECJS_RUNTIME=FastNode`\n\n```\n$ EXECJS_RUNTIME=FastNode bin/console\n\u003e ExecJS.runtime\n=\u003e #\u003cExecJS::FastNode::ExternalPipedRuntime:0x005599c0d38740 @name=\"Node.js (V8) fast\"...\n\n$ EXECJS_RUNTIME=Node bin/console\n\u003e ExecJS.runtime\n=\u003e #\u003cExecJS::ExternalRuntime:0x00559c440347c0 @name=\"Node.js (V8)\" ...\n```\n\n## Why not upstream this to execjs?\n\nI'd like to, but it will take time. The goal of this endeavour is to give users a fast ExecJS runtime without needing any additional dependencies, just a Node.js installation. However most users don't (and shouldn't have to) think about ExecJS and need it to Just Work. This is a pretty significant change and it probably won't \"Just Work\" right now, and more time is needed to tell if it can.\n\nI have sent a pull request upstream to [use vm.runInContext](https://github.com/rails/execjs/pull/55), which would be the first step to merging this upstream.\n\n## Why not just use therubyracer?\n\nMaybe you should, if you need the speed.\n\nHeroku [recommends againts it](https://devcenter.heroku.com/articles/rails-asset-pipeline#therubyracer) as do various stack overflow answers with vague mentions of high memory usage.\nI haven't seen any benchmarks or bug reports that demonstrate this, so I consider these claims somewhat suspect.\n\n[mini_racer](https://github.com/discourse/mini_racer) is another option.\n\nThe ExecJS Node runtime has its benefits as well. It should work on jRuby and other non-MRI runtimes.\nIf this were merged upstream it would give developers fast javascript execution without needing an extra gem or configuration, just a working `node` somewhere in `$PATH`.\n\n## Limitations\n\n* Syntax errors on Node.js versions 0.10.x and 4.x can't report the exact line number of the error. Instead they will always display `(execjs):1`.\n* This only runs a single node process, so javascript execution can only make use of a single processor. This isn't much of an issue because sprockets doesn't parallelize builds. This runtime is so much faster than the original that this would only be an issue with very specific use cases.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/jhawthorn/execjs-fastnode.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhawthorn%2Fexecjs-fastnode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhawthorn%2Fexecjs-fastnode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhawthorn%2Fexecjs-fastnode/lists"}