# Degrading gracefully - how to tell if JS is enabled?

**URL:** <https://www.ruby-forum.com/t/degrading-gracefully-how-to-tell-if-js-is-enabled/97229>\
**Category:** Rails\
**Created:** [July 5, 2006, 8:48pm UTC](https://www.ruby-forum.com/t/degrading-gracefully-how-to-tell-if-js-is-enabled/97229 "2006-07-05T20:48:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [July 5, 2006, 8:48pm UTC](https://www.ruby-forum.com/t/degrading-gracefully-how-to-tell-if-js-is-enabled/97229/1 "2006-07-05T20:48:11Z")

</div>

Is there a RoR best practice wrt determing in a visitor’s browser has JS  
disabled? Is there even a way to find out? I’ve got a couple of pages  
in my app that are not going to degrade gracefully at all. I really  
need to point a visitor who has JS disabled down a seperate path. Any  
ideas?

Thanks,  
Bill

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [July 5, 2006, 8:57pm UTC](https://www.ruby-forum.com/t/degrading-gracefully-how-to-tell-if-js-is-enabled/97229/2 "2006-07-05T20:57:24Z")

</div>

On 7/5/06, Bill W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a RoR best practice wrt determing in a visitor’s browser has JS  
> disabled? Is there even a way to find out? I’ve got a couple of pages in  
> my app that are not going to degrade gracefully at all. I really need to  
> point a visitor who has JS disabled down a seperate path. Any ideas?

This works with Firefox. No idea how IE handles it.

Put this somewhere inside your HEAD element. Change the URL to  
something meaningful.

– James

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [July 5, 2006, 9:03pm UTC](https://www.ruby-forum.com/t/degrading-gracefully-how-to-tell-if-js-is-enabled/97229/3 "2006-07-05T21:03:48Z")

</div>

On 7/5/06, Bill W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a RoR best practice wrt determing in a visitor’s browser has JS  
> disabled? Is there even a way to find out? I’ve got a couple of pages in  
> my app that are not going to degrade gracefully at all. I really need to  
> point a visitor who has JS disabled down a seperate path. Any ideas?

It depends what you want to do.

You could have a split at the very beginning of your site. I haven’t  
tested this

[enter site](http://domain.com/site_without_javascript)

You could use this at any particular link within your site as well.  
Maintaining two sets of views wouldn’t be DRY.

Or for just a few places that need special attention you can use the  
 tags. For a simple drop-down box form you can have a button  
appear for people without Javascript.

 options in here 
- Peter

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [July 5, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/degrading-gracefully-how-to-tell-if-js-is-enabled/97229/4 "2006-07-05T21:07:05Z")

</div>

On Wed Jul 05, 2006 at 01:54:32PM -0500, James L. wrote:

> 

the raelian way to gracefully degrade is something like

respond.to do |type|  
type.js {render rjs}  
type.html {redict to blahblah, where rhtml is rendered}  
end

not the xact syntax…

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [July 7, 2006, 3:08am UTC](https://www.ruby-forum.com/t/degrading-gracefully-how-to-tell-if-js-is-enabled/97229/5 "2006-07-07T03:08:42Z")

</div>

On 7/5/06, Bill W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a RoR best practice wrt determing in a visitor’s browser has JS  
> disabled? Is there even a way to find out? I’ve got a couple of pages in  
> my app that are not going to degrade gracefully at all. I really need to  
> point a visitor who has JS disabled down a seperate path. Any ideas?

Hi Bill,

I just made a controller that degrades gracefully using respond\_to  
with html and rjs templates. I’m not sure who really has JavaScript  
disabled in their browser but I was very pleased with how little extra  
work it took to accommodate both. Maybe an extra 20 lines of code. For  
something like a store front, where every sale is critical, this might  
be a good approach.

Peter
