Javascript graceful degradation in symfony 1.0
Even though in this day and age of Javascript, most people do not really think about this anymore, it can still be important to have your site working when someone either has no javascript or has it turned off. It does happen, so you better think about it a bit. Symfony has some neat features for graceful degradation.
Some people who may not be able to access (all of) Javascript:
- Blind people with non-js screenreaders
- People who actively turn off javascript
- People behind corporate firewalls
- Search engines
I am sure there are more groups that can be thought of, but these four are probably the most common who have trouble with an interface using Javascript/AJAX. And you may not care about an individual group of the list above, but there's a big chance that one of these groups at least will fall inside the target audience of your web application. And it's not that hard to support those people as long as you keep it in mind from the start.
The easiest approach by far is to first write your application completely without Javascript. That means your application works in most common browsers, assuming of course you have correct (X)HTML and CSS, but that is outside the scope of this post. If you have such an application running, you can easily now start expanding your application by using the graceful degradation features of symfony. These features are basically nothing more than two helper functions:
if_javascript();
//Your javascript-based code goes here
end_if_javascript();
Anything that goes between these two functions, will only be outputted if the browser supports Javascript. Easy, but what about our old code? We don't want to have that displayed if there is Javascript support available. Well, for that, there is the good old <noscript>-tag in HTML. So, here is what your code may look like before the extending of your functionality with Javascript:
<!-- Nice piece of regular HTML functionality -->
And now, here it is as extended with Javascript:
<?php
if_javascript();
//Your javascript-based code goes here
end_if_javascript();
?>
<noscript>
<!-- Nice piece of regular HTML functionality -->
</noscript>
Symfony will ensure that the Javascript-based code will only be shown if Javascript is supported, and the browser will ensure that anything between <noscript>-tags will be ignored if Javascript is enabled. Powerful and easy.
May 18, 2008 - tags: php, symfony, javascript, graceful degradation, usability, accessibility
jack: Another option: use javascript to hide any functionality that is only there for non-javascript-enabled users. This takes away the need for the extra markup of the noscript tag. Could be a matter of personal preference/project specs, though.
The Daily Herald: In the present time it is important to know about languages in order to move forward in the field of IT. Thanks for providing info about this topic here. Keep it up
place to know about business status: It is a good addition for all those who are behind the firewalls. Good sharing from your side. But you must try to mention it's procedure, as it will be good enough for all of us.
classifieds homes los angeles: Symfony really has some features for graceful degradation.mostly peoples like these features.i like your post you do good effort to make it more valuable.
thanks for sharing.
florida spray foam insulation: There is nothing better then using javascript. I think the options are endless for this. There is nothing better then this.
goose jackets: thanks a lot,best regards!
lqeswck: It is a good addition for all those who are behind the firewalls. Good sharing from your side. But you must try to mention it's procedure, as it will be good enough for all of us.
Toyota Cars: Interesting topic what you have shared with us. Your writing skill is really very appreciative. I love when you share your views through the best articles.Keep sharing and posting articles like these.This article has helped me a lot.Keep posting this stuff.
coach outlet online: If you buy Coach items at the
coach outlet online
store, the goods will be sent out within 24 hours after confirming your payment and arrive to your door within 7 work days.No one can deny the shopping at the
coach factory outlet
is satisfactory. For the low prices and good quality.
coach outlet: coach outlet
handbags You can not just save your cash but also your time inside a convenient way to obtain the exact same bags product and do not be concerned the shippment of one's products.The
coach outlet store online
are utilized for formal event in company area that will display your excellent taste.Not only does a briefcase make is easier to carry things.
discount uggs boots: I am typically to running a blog and i really respect your content. The article has really peaks my interest.
michael michael kors: Really appreciate this wonderful post that you have provided for us. Great site and a great topic as well i really get amazed to read this.
Supporting Providers: Unmake is everything, so we pauperism to subvent that there are values on what we are clinical to protect our subscribers hypnotised. Sue them nettled is one belief we moldiness enounce do!
Diamond Sofa: I really liked reading your post!. Quallity content. With such a valuable blog i believe you deserve to be ranking even higher in the search engines
ashley furniture: You write Formidable articles,keep up good work.
caplan syndrome: Really appreciate this wonderful post that you have provided for us. Great site and a great topic as well i really get amazed to read this.
How to Select House Plans: Interesting topic what you have shared with us. Your writing skill is really very appreciative. I love when you share your views through the best articles.Keep sharing and posting articles like these.This article has helped me a lot.Keep posting this stuff.