Jump to content
Stef's Coding Community
Sign in to follow this  
Woody

Turning Off JavaScript?

Recommended Posts

Hi there...Can anyone tell me why someone would turn javascript OFF on their browser (assuming that's where it is done)? I'm learning jQuery, etc., on Killersites U. and I'd like to know before I load up my site with JavaScript. Thanks in advance.

Share this post


Link to post
Share on other sites

The only reason in my mind would be that Javascript could be a potential security risk. However, I believe that 98-99% of people have Javascript turned on in their browser.

 

In general, when I use Javascript, I try to make sure that the site will degrade gracefully and is still fully functional even if Javascript is turned off.

Share this post


Link to post
Share on other sites

Thanks again Ben.

 

 

and is still fully functional even if Javascript is turned off.

 

Any suggestions as to where I could learn how to do this?

Share this post


Link to post
Share on other sites

Some if it is common sense. Some of it you can pick up yourself by disabling Javascript in your browser and testing your site. Some you'll just pick up as you get more experienced. Overall though, I imagine this isn't something you need to worry that much about if you are just starting out with Javascript/jQuery. It only becomes an issue if you are building in functionality that stops the user being able to use the site if Javascript is disabled.

Share this post


Link to post
Share on other sites

Let's say you have a jQuery image gallery scroll control on your site, it looks nice and functions beautifully. You turn off javascript to see what it look like, your whole site looks a mess now with images all over the place, styling is messed up, etc.

 

The best way to make your site degrade gracefully and function with or without javascript is to build it without javascript first, then add the bells and whistles later. Let's take that image gallery example, and see how we can make it degrade gracefully.

 

How do you want it to function without javascript? Do you want to hide it with CSS and let javascript show it? Do you want to allow some user interaction even if they don't have javascript enabled? This is what I would do, I would make a couple of wrapper divs for the control, like so:

 

<div id="imgGalleryWrapper">
 <div id="imgGalleryScroll">
   <!-- images here -->
 </div>
</div>

 

Then I would set the height and width's of the divs with CSS:

 

#imgGalleryWrapper{
 width:250px;
 height:250px;
 overflow:auto; /* this will make scrollbars show up if the content in the div goes beyond the set boundaries */
}

#imgGalleryScroll{
 width:500px; /* making it wide to accommodate the images for scrolling */
 height:250px;
}

 

Now that we have the HTML and CSS in place, look at the page and you'll see a nice section for your images. That is what it will look like without javascript. Now let's take away the scrollbars with jQuery:

 

$(document).ready(function(){
 $('#imgGalleryWrapper').css('overflow', 'hidden');
});

 

So if the user has javascript enabled, then they won't see the scrollbars no matter how many images are in the #imgGalleryScroll div.

 

That's just a very short and sweet way of making great degrading, there's many ways you can do so. You could get way more advanced than this. I didn't mean to type so much, just like to explain how I work, that's how I've built my companies site.

Share this post


Link to post
Share on other sites

I'm one of the few people who often have javascript disabled.

 

I find that many javascript features are annoying. Several forums I look at underline certain words in posts with double green lines and color them green and convert the words into links which take a user to an ad or some other part of the forum which is totally unconnected with the post. For instance if you post the word pension the green link takes you to a page which may be vaguely related to pensions but not at all related to your post.

 

I also find some image features annoying when they move or flicker.

 

I enable javascript when I find I need it, like bank accounts, online purchases, downloading programs and the like.

Share this post


Link to post
Share on other sites

Thanks Ben, Kyle, and Wickham, for your informative responses. I will endeavor to make use of this new knowledge as I continue my Web-related pursuits.

Share this post


Link to post
Share on other sites

To add to the list... some corporations, schools or companies will disable JavaScript for security reasons.

 

Then there are the alternative user agents that do not support JavaScript, it can range from smart Phone browsers to assistive technologies like portable web readers and Braille readers used by the vision impaired community. Also consider game consoles that connect online or the portable game consoles.

 

Futuristic considerations, there are countries in the East and Europe who already allow online payment of train tickets or a soda from a machine, as more things become available JavaScript may or may not be supported. One vision is a refrigerator that keeps track and orders new groceries online, it may have to use a web interface but likely would not support JavaScript, same for a coffee machine that orders more coffee.

 

Finally the most profound and unconsidered reason even if 99% of users have it turned off, 100% of users CAN turn it off! What if a new virus hits using JavaScript? Snap, 99% of the users have it turned off and my site needs it!

 

Also what is it used for in any one case? Ever see a web site where the images or further entrance is based on JavaScript? Turn it off and suddenly you have access...

 

There are things JS is great at, but just consider if any other technology can do the same thing without requiring anything from the users side... use that technology before JS.

Share this post


Link to post
Share on other sites

I always just felt that if it can be done server side do it... then nothing the user does will mess it up.

 

Those things that JavaScript/Ajax can only do... it is fine to use it then.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...