On Dec 16, 2011, at 10:05 AM, Claus Reinke wrote:

> There is a widespread pattern on the web that I don't understand.
<snip>
> The problem is that users who disable Javascript by default see
> nothing at all on such sites, even though the content could be read just fine 
> by removing the default styling. Try the example.

I agree that this is a problem (or "anti-pattern").
> 
> If the rationale above is correct, there would seem to be a simple 
> workaround, which is to hide content via a css class, and to attach that 
> class dynamically, before the content is parsed and rendered.
> That way content is hidden by default only when script is enabled:

This is the approach I've taken, as well, except I'd recommend adding the class 
the the html element and put the script in the <head>. I  actually thought this 
approach was pretty widespread, as well. But maybe not. Anyway, I wrote about 
it three years ago: 
http://www.learningjquery.com/2008/10/1-way-to-avoid-the-flash-of-unstyled-content

It basically recommends doing this:

<html>
<head>
  <!-- etc. -->
  <script>document.documentElement.className = 'js';</script>
  <!-- etc. -->

Probably a safer way to do this, in case a className is already there, is 

document.documentElement.className += ' js';

--Karl

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to