# RJS - What the the advantages? / Why use?

**URL:** <https://www.ruby-forum.com/t/rjs-what-the-the-advantages-why-use/82026>\
**Category:** Rails\
**Created:** [January 16, 2007, 10:47pm UTC](https://www.ruby-forum.com/t/rjs-what-the-the-advantages-why-use/82026 "2007-01-16T22:47:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [January 16, 2007, 10:47pm UTC](https://www.ruby-forum.com/t/rjs-what-the-the-advantages-why-use/82026/1 "2007-01-16T22:47:53Z")

</div>

Hi,

I’ve read up on RJS and understand the concept/how-to-use. It’s still  
not  
clear in my mind when and why to use RJS? Can anyone drop in a couple  
of  
bullet points re advantages + when/why would RJS make sense?

Thanks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [January 16, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/rjs-what-the-the-advantages-why-use/82026/2 "2007-01-16T23:17:35Z")

</div>

RJS makes javascript easy. purchase the 6 dollar tutorial on RJS by  
orielly. after building the sample application, you will definitly see  
the benefit vs trying to use ajax.

Greg H. wrote:

> Hi,
> 
> I’ve read up on RJS and understand the concept/how-to-use. It’s still  
> not  
> clear in my mind when and why to use RJS? Can anyone drop in a couple  
> of  
> bullet points re advantages + when/why would RJS make sense?
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [January 17, 2007, 12:55am UTC](https://www.ruby-forum.com/t/rjs-what-the-the-advantages-why-use/82026/3 "2007-01-17T00:55:19Z")

</div>

> I’ve read up on RJS and understand the concept/how-to-use. It’s still not  
> clear in my mind when and why to use RJS? Can anyone drop in a couple of  
> bullet points re advantages + when/why would RJS make sense?

Not really a bullet point, but RJS/ajax makes building a “video player”  
extremely easy and very friendly… for my player I have a list of  
channels, a playlist, and the video itself.

Click a channel and the only thing that updates is the playlist/video.  
Click on an entry in the playlist, only the video updates.  
Click the “next page” link in the playlist, and the playlist updates and  
the video…

Click the “add to favorites” and the only thing that updates is that  
link  
with a message that now reads “remove from favorites”.

Basically it stops me from having to refresh the entire page for every  
action…

-philip

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [January 17, 2007, 4:11am UTC](https://www.ruby-forum.com/t/rjs-what-the-the-advantages-why-use/82026/4 "2007-01-17T04:11:40Z")

</div>

Tks - so from the point of ease in coding javascript there is an  
advantageous. What about from a design/architecture/performance  
perspective?

Note I’m asking about the RJS templates concept, not about AJAX (i.e.  
one  
could I assume build an AJAX type feature with or without RJS).

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [January 17, 2007, 4:45am UTC](https://www.ruby-forum.com/t/rjs-what-the-the-advantages-why-use/82026/5 "2007-01-17T04:45:45Z")

</div>

Greg H. wrote:

> Tks - so from the point of ease in coding javascript there is an  
> advantageous. What about from a design/architecture/performance  
> perspective?

Most applications are multilingual, so most applications should put as  
much  
code as possible in one language. Ruby makes “Domain Specific Languages”  
spectacularily easy, so you should only write raw SQL if you can’t find  
an  
ActiveRecord way to do things, and you should only write raw JavaScript  
if  
you can’t find an RJS way to do things.

The advantage is you can refactor freely, and improve your design,  
architectures, and development speed, by putting code together by the  
affinity of its concepts, not by what language it happens to be in.

Curiously, I prefer Builder::XmlMarkup over the raw HTML in rhtml files.  
But  
HTML is special where we must preserve compatibility with graphic  
designers…

–  
Phlip  
[Redirecting...](http://www.greencheese.us/ZeekLand) ← NOT a blog!!!
