From: Florian Gilcher Date: 2013-01-09T18:20:21+09:00 Subject: Re: Can I require an external .js file in Ruby On Jan 9, 2013, at 12:54 AM, Hassan Schroeder wrote: > On Tue, Jan 8, 2013 at 3:19 PM, Jeremy Bopp wrote: > >>> Is there a way to include .js functions within my ruby script? >> >> The Ruby interpreter can only directly run Ruby code. Javascript is not >> Ruby, obviously, so the only possible solution would be to find a way to >> load a Javascript interpreter > > e.g. `gem install johnson` -- https://github.com/jbarnette/johnson > > Note: haven't used this in a long time, so can't vouch for suitability > for whatever particular purpose the OP has in mind. :-) There are multiple mature ways to embed a JS interpreter in Ruby: gem install therubyracer # V8 embedded in Ruby gem install therubyrhino # the same for JRuby, using Rhino See https://github.com/cowboyd/therubyracer for the README Be aware that this only gives you the javascript interpreter, not access to DOM manipulations etc.