Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>no-js</code> class is used by the <a href="http://modernizr.com/" rel="noreferrer">Modernizr</a> feature detection library. When Modernizr loads, it replaces <code>no-js</code> with <code>js</code>. If JavaScript is disabled, the class remains. This allows you to write CSS which easily targets either condition.</p> <p>From <a href="https://web.archive.org/web/20130511051108/http://modernizr.github.io/Modernizr/annotatedsource.html#section-103" rel="noreferrer">Modernizrs' Anotated Source</a> <a href="https://github.com/Modernizr/Modernizr/issues/417" rel="noreferrer"><em>(no longer maintained)</em></a>:</p> <blockquote> <p><em>Remove "no-js" class from element, if it exists:</em> <code>docElement.className=docElement.className.replace(/\bno-js\b/,'') + ' js';</code></p> </blockquote> <p>Here is a blog post by Paul Irish describing this approach: <a href="http://www.paulirish.com/2009/avoiding-the-fouc-v3/" rel="noreferrer">http://www.paulirish.com/2009/avoiding-the-fouc-v3/</a></p> <hr> <p>I like to do this same thing, but without Modernizr. I put the following <code>&lt;script&gt;</code> in the <code>&lt;head&gt;</code> to change the class to <code>js</code> if JavaScript is enabled. I prefer to use <code>.replace("no-js","js")</code> over the regex version because its a bit less cryptic and suits my needs.</p> <pre><code>&lt;script&gt; document.documentElement.className = document.documentElement.className.replace("no-js","js"); &lt;/script&gt; </code></pre> <p>Prior to this technique, I would generally just apply js-dependant styles directly with JavaScript. For example:</p> <pre><code>$('#someSelector').hide(); $('.otherStuff').css({'color' : 'blue'}); </code></pre> <p>With the <code>no-js</code> trick, this can Now be done with <code>css</code>:</p> <pre><code>.js #someSelector {display: none;} .otherStuff { color: blue; } .no-js .otherStuff { color: green } </code></pre> <p>This is preferable because:</p> <ul> <li>It loads faster with no FOUC (flash of unstyled content)</li> <li>Separation of concerns, etc...</li> </ul>
    singulars
    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. 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.
    3. VO
      singulars
      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