I think it is a good idea to ask a user to enable JavaScript if they wish to use an interactive feature on you're site that REALLY requires it.
I would also say that it is bad UX to have them turn it if all it will do is fix a few layout issues, or anything simple like that.
Also ask yourself: Do I really need JavaScript for this feature; or can I implement it without JavaScript and just use JavaScript to enhance it?
There should be a compelling reason to have the user enable JavaScript, so that if they do, then they will see/experience the real benefit of doing so. Otherwise this could lead them to distrust your site and others that may ask them afterward. Also explain to your users what benefits they'll get if they turn it on. Don't leave them guessing.
Reasons I think are good:
- Live/Real-time updates (example: stock exchange/rss feeds).
- Performance gain in page load times by bringing in content via AJAX.
- Ease of use, kKeep the user from jumping through too many pages in order to accomplish a task.
- Game/Canvas interaction.
Google Gmail is good example of when you should ask, in fact they do. Google even goes as far as to give you a little tutorial on how to enable JavaScript, if your browser supports it. However, they also give you an alternative HTML version of Gmail that does not require JavaScript. Of course it does not have all the bell and whistle.
Get an feel/understanding of how others handle this by disabling JavaScript and then surfing the web to a couple of your favorite sites that use JavaScript heavily, and see how they deal with users that disable JavaSCript. I know Gmail does, .