What is therubyracer or libv8 in rails app?

I worked on a project and often had problems with therubyracer and libv8, so I decided to remove them. It seemed that the only thing that used them as a dependency was less - the rails, which I wanted to remove anyway.

My main question is: why are they needed and are they needed in the average application, and if so, why?

+6
source share
2 answers

There are several things for which a Rails application can use the Javascript Runtime:

1) The Rails Asset Pipeline requires a Javascript Runtime to be executed to compress Javascript.

2) Some Rails ActionView Helpers , such as javascript_include_tag, require a Javascript Runtime to execute in order to execute Javascript functions.

Not all Rails applications use these features, so the reason therubyracer gem is initially commented on in your Gemfile; Also, note that you can use NodeJS as your Javascript runtime.

See details

http://guides.rubyonrails.org/asset_pipeline.html#javascript-compression

http://www.rubydoc.info/docs/rails/ActionView/Helpers/JavaScriptHelper

http://www.rubydoc.info/docs/rails/ActionView%%FFelpers%2FAssetTagHelper%3Ajavascript_include_tag

The right "Rails" way to execute javascript on specific pages

+9
source

rubyracer provides the following features:

1. We can write your ruby codes inside js codes. 2. We can invoke the js functions from ruby codes. 3. Manipulation of javscript objects & the passing them to javascript functions. 

Here are a few key benefits of using gems in rubir. Please read the full information here.

+2
source

Source: https://habr.com/ru/post/980958/


All Articles