# RJS templates outputting bloated code?

**URL:** <https://www.ruby-forum.com/t/rjs-templates-outputting-bloated-code/56549>\
**Category:** Rails\
**Created:** [April 1, 2006, 12:46am UTC](https://www.ruby-forum.com/t/rjs-templates-outputting-bloated-code/56549 "2006-04-01T00:46:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yariv\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/13edae/32.png) [@Yariv\_S](https://www.ruby-forum.com/u/Yariv_S)\
**Post date:** [April 1, 2006, 12:46am UTC](https://www.ruby-forum.com/t/rjs-templates-outputting-bloated-code/56549/1 "2006-04-01T00:46:29Z")

</div>

I’m an RJS newbie. I just did the tutorial at  
[http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates](http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates), and  
then used wget to look at the output the RJS template generates. This is  
what I got:

try {  
new Insertion.Bottom(“list”, “

- Fox
”);  
new Effect.Highlight(“list”,{duration:1});  
Element.update(“header”, “RJS Template Test Complete”);  
} catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert(‘new  
Insertion.Bottom("list", "- Fox
");\nnew  
Effect.Highlight("list",{duration:1})  
;\nElement.update("header", "RJS Template Test Complete");’); throw  
e }

It looks to me like the exception handling logic sent in the response  
causes too much bloat. I think it’s better to send only the “meat”:

new Insertion.Bottom(“list”, “

- Fox
”);  
new Effect.Highlight(“list”,{duration:1});  
Element.update(“header”, “RJS Template Test Complete”);

Thoughts?

---

<div class="post-metadata">

**Author:** ![Yariv\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/13edae/32.png) [@Yariv\_S](https://www.ruby-forum.com/u/Yariv_S)\
**Post date:** [April 1, 2006, 1:00am UTC](https://www.ruby-forum.com/t/rjs-templates-outputting-bloated-code/56549/2 "2006-04-01T01:00:44Z")

</div>

On 3/31/06, Yariv S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Insertion.Bottom("list", "
> 
> - Fox
> ");\nnew  
> Element.update(“header”, “RJS Template Test Complete”);
> 
> Thoughts?

Hi. This behavior only exists (by default) in development. Look at  
your config/environments/development.rb file and you should see a  
setting for RJS debug. This will help you during development but it  
shouldn’t show up on production.

–  
Chad F.  
[http://chadfowler.com](http://chadfowler.com)  
[http://pragmaticprogrammer.com/titles/fr\_rr/](http://pragmaticprogrammer.com/titles/fr_rr/) (Rails Recipes - In Beta!)  
[http://pragmaticprogrammer.com/titles/mjwti/](http://pragmaticprogrammer.com/titles/mjwti/) (My Job Went to India,  
and All I Got Was This Lousy Book)  
[http://rubycentral.org](http://rubycentral.org)  
[http://rubygarden.org](http://rubygarden.org)  
[http://rubygems.rubyforge.org](http://rubygems.rubyforge.org) (over one million gems served!)

---

<div class="post-metadata">

**Author:** ![Yariv\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/13edae/32.png) [@Yariv\_S](https://www.ruby-forum.com/u/Yariv_S)\
**Post date:** [April 1, 2006, 2:37am UTC](https://www.ruby-forum.com/t/rjs-templates-outputting-bloated-code/56549/3 "2006-04-01T02:37:46Z")

</div>

On 3/31/06, Yariv S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Hi. This behavior only exists (by default) in development. Look at  
> > your config/environments/development.rb file and you should see a  
> > setting for RJS debug. This will help you during development but it  
> > shouldn’t show up on production.
> 
> Excellent! I knew you guys have probably thought of this 🙂 Keep up the  
> great work!

Well, I can’t personally claim to have thought of anything other than  
asking Sam S. recently about the best ways to debug RJS, which  
is when he told me about this feature 🙂

–  
Chad F.  
[http://chadfowler.com](http://chadfowler.com)  
[http://pragmaticprogrammer.com/titles/fr\_rr/](http://pragmaticprogrammer.com/titles/fr_rr/) (Rails Recipes - In Beta!)  
[http://pragmaticprogrammer.com/titles/mjwti/](http://pragmaticprogrammer.com/titles/mjwti/) (My Job Went to India,  
and All I Got Was This Lousy Book)  
[http://rubycentral.org](http://rubycentral.org)  
[http://rubygarden.org](http://rubygarden.org)  
[http://rubygems.rubyforge.org](http://rubygems.rubyforge.org) (over one million gems served!)

---

<div class="post-metadata">

**Author:** ![Yariv\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/13edae/32.png) [@Yariv\_S](https://www.ruby-forum.com/u/Yariv_S)\
**Post date:** [April 1, 2006, 1:07am UTC](https://www.ruby-forum.com/t/rjs-templates-outputting-bloated-code/56549/4 "2006-04-01T01:07:30Z")

</div>

> Hi. This behavior only exists (by default) in development. Look at  
> your config/environments/development.rb file and you should see a  
> setting for RJS debug. This will help you during development but it  
> shouldn’t show up on production.

Excellent! I knew you guys have probably thought of this 🙂 Keep up the  
great work!

Yariv
