Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First let me say that there's no hard and fast rule to your question and imo it voices down to personal preference for specific situations. Here are some considerations to help you along:</p> <blockquote> <p>First I think that the html output from the server should be mainly for those that don't have js or if there's a browser bug. That way the page will work for everyone I hope.</p> </blockquote> <p>You are talking about "<a href="http://en.wikipedia.org/wiki/Progressive_enhancement" rel="nofollow">Progressive enhancement</a>" which is a strategy to increase "accessibility" to your website. To do so, you would plan and develop a user experience that works for folks who don't have Javascript enabled before you add-on Javascript to enhance that experience for those who do have it enabled. You should plan in your design what kind of functionality is "lost" when Javascript is not available - Simplistically put - good "accessibility" is when the main task like say "submitting a form" still works without Javascript.</p> <p>You're also asking if you should output hidden html elements that are meant only for the 'enchanced Javascript experience' in the HTML or should you 'generate' it on the fly using Javascript. This brings us to another term - "<a href="http://%20http://en.wikipedia.org/wiki/Unobtrusive_JavaScript" rel="nofollow">Unobtrusive JavaScript</a>".</p> <p>One school of thought is to never put any thing that is meant for the javascript-only experience in your html page and use Javascript itself to add those stuff to the <a href="http://en.wikipedia.org/wiki/Document_Object_Model" rel="nofollow">DOM</a>. The advanage to that is that you will have a cleaner, more lightweight and portable html page.</p> <p>Another school of thought is to be less "purist" and more "practical" - meaning do what is most efficient. Don't write an extra 100 lines of Javascript code and spent an extra 2 hours if you can simply add the extra code directly to the HTML page and hide it with css.</p> <p>I personally believe that as programmers we should always consider the business value when making these decisions. Ask yourself things like "How much time should i spent to do this?", "am I creating a website for 5 hundred or 5 million users?". Basically, don't use an grenade to kill a mice ;)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload