A file with .rjs extension contains Ruby code and JavaScript. It allows Rails developers to use Ruby to produce dynamic JavaScript code. Ruby code is embedded in JavaScript functions. It is compiled o...
A file with .rjs extension contains Ruby code and JavaScript. It allows Rails developers to use Ruby to produce dynamic JavaScript code. Ruby code is embedded in JavaScript functions. It is compiled on the web server running Ruby engine. RJS is similar to RHTML. The only difference is RHTML contains Ruby code in HTML while RJS contains Ruby code in JavaScript functions.
RJS files are coded in plain text like other scripting languages. When requested by client, Ruby code executes on server. Only HTML and JavaScript code return to client’s browser.
RJS files can be viewed in a Web browser. But Ruby code parses on the web server before sending the page to the client. So the user only sees HTML and JavaScript code.