How much I need to consider the seneraio of JavaScript disabled?

Hi there

I am working on a web application.While I am considering that JavaScript is disabled in the client browser.So How much I consider it.Like I have used many times JQuery in My Project.If javaScript is disabled then this code is not working?

What are real possible seneario of it?

Thanks

I don’t know the numbers (percentage of users who disable JavaScript), but it should always be taken into consideration.

If the application is heavily dependent upon JS, then you might want to figure some kind of alert to let users know that JS is critical to the application.

If the application is NOT heavily dependent upon JS, then it would probably be a good idea to come up with a contingency plan for allowing things to gracefully degrade.

V/r,

:slight_smile:

I have tried this before
but not able to get a clear working code of it

How to detect that a user has disabled in javascript or not.
like in stackoverflow.com if we disable java then a red message appear on the top

How do I acheive this?

<noscript> HTML tag is what you are looking for.

anything placed in the

<noscript></noscript>

Tags will show for browsers with JS disabled.

I have read somewhere(By googling) that using <noscript></noscript>
is not a good idea to check if Javascript is disabled or enabled

Ideally you should have a working and functional page without it. You shouldn’t try and force users to use Javascript on your page.

Ideally, yes. I think a lot of that, however, would depend upon how much “flash and wow” you want or need. If you are not as concerned with DOM manipulation and flashy aesthetics, you can do the application with no JavaScript.

But, if you want to be able to submit form data in the background via AJaX, then that makes things slightly more difficult.

:slight_smile:

How could I detect javaScript is enabled or not?

Any code snipshot

The only way that I know of is to use JavaScript to detect if JavaScript is enabled, or not. But if JavaScript is disabled, it won’t work. :smile:

:slight_smile:

You shouldn’t need to detect whether it’s enabled. Just have a base website that works. Decent functionality. You are happy with it.

Then use Javascript to add upon it and make it better. You shouldn’t detect whether JS is enabled.

So Funny. :sunglasses:

This might give an simple Idea rather than brainstorming on technical aspects :innocent:

Let’s say you are working on a navigation menu. Ok just go here (code funda mentals . com) with / without JS on (broke up the URL to not get called a spammer/blasted by mods.)

Desktop WITHOUT Javascript → Horizontal Menu. Nothing special
Desktop WITH Javascript → You get the added benefit of it being a sticky navigation. Go scroll down and see it follows you. Simple upgrade of UX.

Mobile WITHOUT Javascript → Vertical menu that appears at the top of the page.
Mobile WITH Javascript → I use JS to turn this into a hamburger menu which is much preferred in the mobile web, rather than a silly vertical menu.

Javascript should be used to enhance the user experience of the webpage. Use it responsibly and for features that make the users life better. But also make it so you don’t detract from the functionality of hte page without Javascript. Get a working version of your page without Javascript first, then use JS to increase the UX :slight_smile: .

Great Points

thanks

Instead of using noscript tags you could have something like

<div id="js_message">This site works better with JavaScript enabled</div>

then use JavaScript to display: none it

5 Likes

Those tags are long obsolete (the last browser that needed them was Netscape 4). Since then it has been far easier to detect whether JavaScript is enabled or not using JavaScript (as Mittineague illustrates)

1 Like

What benefit does this offer that noscript does not? Why choose that over noscript?

Genuinely curious. I’m no expert.

It might be that HTML5 has reintroduced it? eg. this very Discourse site has noscript tags

    <noscript data-path="/t/how-much-i-need-to-consider-the-seneraio-of-javascript-disabled/117498/16">
      <header class="d-header">
        <div class="container">
          <div class="contents">
            <div class="row">
              <div class="title span13">
                <a href="/"><img src="http://www.sitepoint.com/wp-content/themes/sitepoint/assets/svg/sitepoint.svg" alt="The SitePoint Forums" id="site-logo"></a>
              </div>
            </div>
          </div>
        </div>
      </header>
... 

Then again, this site is severely crippled without JavaScript enabled.

I wasn’t trying to sell him on the use of the tag. He asked how StackExchange handled the red banner:

<noscript> <div id="noscript-warning">Stack Overflow works best with JavaScript enabled<img src="http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif" alt="" class="dno"></div> </noscript>

noscript is a block level tag so you need to wrap it around an entire paragraph at a minimum. You can use JavaScript and a span tag around as little as a single character and do the same thing.

You can use one line of JavaScript and a CSS class to replace dozens of noscript tags and the corresponding dozens of lines of JavaScript that supply the alternate content.

You can use JavaScript to test for far more than just JavaScript enabled or disabled - you can test for specific commands being available and update the page based on what JavaScript the browser supports .

Basically not using noscript is so much more flexible than using it that only someone who doesn’t know JavaScript properly would even consider using noscript.

HTML 5 did introduce allowing noscript in the head of the page (which was not previously allowed) where you could use it to replace the single line of JavaScript by applying all the changes using CSS instead - but only for JavaScript enabled/disabled, not for any of the thousands of other possibilities you have if you don’t use noscript…

2 Likes