Skip to content
A pure-JavaScript browser environment with early rubygem support.
JavaScript Other
Find file
Pull request Compare This branch is 207 commits ahead, 328 commits behind thatcher:master.
Latest commit 0a5606b Feb 2, 2012 @smparkes Update README.rdoc
Failed to load latest commit information.
DTD theres a hole in the bucket Nov 18, 2008
bin remove tidy Jan 20, 2011
dist merge 1.1rc1 (i think) Nov 25, 2009
gm gm example Mar 11, 2010
htmlparser merge from thatcher Nov 17, 2009
jsl oops I think I just commited incorrectly Jan 15, 2009
lib whoops jumped the gun on release number ... Sep 14, 2010
licenses merging glens envjs.main changes. used in combo with jline its like w… Aug 26, 2009
rhino Added support for the "quit" command/function provided by the Rhino s… Oct 14, 2009
src missing // on host when doing a hash-only assign Nov 5, 2010
test It would appear that only defining a getter for the value property of… Sep 16, 2010
.gitignore dont remove the gemspec so it can be used via gh May 19, 2010
.jslintrbrc add jslintrb infra Mar 30, 2010
.project added xpath and xslt related stubs to satisfy prototype compat part o… May 20, 2009
CHANGELOG.rdoc whoops jumped the gun on release number ... Sep 14, 2010
Makefile did some refactoring of Glen E. Iveys substantial iframe contribution… Aug 16, 2009
Manifest.txt don't include all the various bin files in the gem Sep 15, 2010
README.rdoc Update README.rdoc Feb 2, 2012
Rakefile add gemspec for use as a git source in bundler Oct 29, 2010
Wakefile fix problem with set history fn name Mar 30, 2010 merged minor conflict, added load event changed, hopefully git is good Nov 24, 2009
build.xml Sigificant refactoring of global scopes and a number of HTML fixes Feb 23, 2010
envjs.gemspec add gemspec for use as a git source in bundler Oct 29, 2010



The Johnson fork of env.js is pretty much mothballed (which is already pretty much true of Johnson, given the rise of v8 and the difficulty moving Johnson to 1.9.*). The current best practices seem to be based on a headless webkit.



A browser environment for javascript interpreters.

This is a fork of the env.js project ( See that link for env.js details. This fork is based on the Johnson Ruby gem (


For now, you can install the envjs gem by installing Johnson:

gem install johnson --prerelease

and then installing the envjs gem with

gem install envjs

Using envjs interactively

The envjs gem provides the envjsrb command, which functions as an extended version of the Johnson javascript shell. For example:

 mbp:env-js smparkes$ envjsrb
 js> this
 => [object Window 0]
 js> window.location
 => about:blank
 js> document.innerHTML
 => "<html><head><title></title></head><body></body></html>"

Embedding envjs

It's also possible to embed the envjs interpreter similar to the way it's done in Johnson, e.g.,

require 'rubygems' # if necessary
require 'johnson/tracemonkey'
require 'envjs/runtime'

envjs =
envjs.extend Envjs::Runtime
window = envjs.evaluate("window")
puts window.location.to_s # == "about:blank"
puts window.document.innerHTML # == "<html><head><title></title></head><body></body></html>"

You need the Runtime#wait at the end to give env.js's event loop a chance to execute queued events and timers. You may need to do this at other times as well, depending on the asynchronous nature of your application.


See and

Something went wrong with that request. Please try again.