treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Do you still use ?

  • Hi there,

    Do you guys still use
    <noscript>
    for people who have JS turned off? I haven't seen anybody using it, just wondering if there's a reason to continue doing so.

    - Steph
  • I still use it!
    I don't like supporting those that have js turned off, but as much of my work is for the education department, and a surprising amount of their laptops have js disabled, i have no choice.
  • You should check out Modernizr.

    Add class="no-js" to your <html> element and it will be removed if JS is loaded. This isn't the only way to do it but it seems to be a very popular method at the moment. I make use of it.
  • Hi

    For a newby - can you explain this feature a bit more ?

    Thanks
  • @fjorko are you asking StephBertha or me?

    I'll explain both:

    The <noscript>:


    Wrap anything within <noscript /> and it will only load if javascript has not loaded. For example:
    <noscript>Please turn on javascript!</noscript>

    <html class="no-js"> & Modernizr:


    Modernizr is very useful. Very basically, it provides feature detection along with some other cool features, such as HTML5 tag support for older browsers.

    Very simply, Modernizr checks to see if <html> has a class of "no-js". If so, it removes it. This way, you could do something like:
    .no-js #slider{display: none;}
    and have the CSS hide a javascript slider or maybe something like
    .no-js #slider li{display: none;}
    .no-js #slider li:first-child{display: block;}

    That would hide all slides except the first.

    Those are just very small examples of how you could use the no-js class.
  • Obviously @fjorko Modernizr is JavaScript and so would only remove the no-js class if JavaScript was enabled. Just thought I would clear that up incase of confusion
  • You do have to be careful when using Modernizr as a fall-back for a site coded in HTML5. Any browser that doesn't support HTML5 and happens to have js turned off will cause some pretty big issues.
  • How big is the percentage of people with JS turned off ? I thought it was around 1%?
  • Correct. On top of that, users with JS turned off are guaranteed to understand that some things will not work properly.
  • Not for what I do unfortunately. Monitoring tells me that roughly 10% of visitors to my sites have js disabled. And what makes it worse is that most of those visitors would not know what javascript is.
  • I still use HTML5 but I just have to be a bit more careful!
  • I just checked Google Analytics and it doesn't say anything about JS support, which I guess is kind of stupid to look as Google also uses a script to monitor stuff? lol

  • Its not stupid - Google Analytics requires javascript to work, so those without it aren't being tracked. It would be redundant to show a javascript statistic showing 100% of trackable users having javascript enabled.
  • @OniLinkCR They certainly do monitor js support, it can be a bit tricky to find though. It's on the Visitors Overview page, under the Browser Profile segment. And js support is currently at about 85% for my sites.
  • All I see is Java...I must be looking at the wrong place.
  • @OniLinkCR I need to learn to read! I assumed it was js without really looking, it is only Java.