Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Lorenzo Minto
Lorenzo Minto
13,898 Points

What happens if someone deactivates the javascript and my site highly relies on jQuery plugins to display content?

In all browser you have the option to switch the javascript off, right?

4 Answers

Ferdinand Pretorius
Ferdinand Pretorius
18,705 Points

There's a web-design philosophy known as Progressive Enhancement which is one you should consider. The idea is you build a basic site that is usable and workable, and then you layer onto this enhancements like jQuery and browser-specific stuff to "enhance" it. This way you get a site that works for everybody and looks nice for the majority.

If that doesn't convince you, then consider other reasons for having a site work without javascript:

  • It is more SEO friendly. If your site relies on JS for content and links then chances are search-engines will be ignoring large chunks of it.

  • Imagine you are an eCommerce site selling widgets. Now, even if only 5% of your customers disable javascript, that is a potential sales loss of 5%. Is it worth losing customers over?

  • Don't discriminate against the disabled. Relying on javascript means your site is not accessible and, in some cases (such as government/public sector sites), you could be breaking the law by discriminating against people.

Ferdinand Pretorius
Ferdinand Pretorius
18,705 Points

Hi Lorenzo,

jQuery is a JavaScript library, if JS is turned of in the browser, anything depending on it will not work.

There are way too many browsers for me to say that all of them has the option to turn it off, however most popular browsers do have the option.

Hope this helps, feel free to ask if you have any more questions on the matter or need a more in-depth answer.

Lorenzo Minto
Lorenzo Minto
13,898 Points

Yes I had already figured out that the jQuery would also not work but what I was worried about is that in some cases (certain kinds of plugins) the whole page can potentially break down without the JS, say you have a Carousel, without the JS some slides would not show at all. Is there a way to prevent that?

Stephen Gheysens
Stephen Gheysens
11,935 Points

Ferdinand is right, it's often an option, but JavaScript is much less commonly blocked by default in today's world. That aside, it's good practice to follow "progressive enhancement" techniques. Essentially, it's keeping in mind that the content (like the text, images, etc. within the HTML) should take precedence, then styling (from CSS), and then extra functionality (from JavaScript and similar technologies). There are a couple of Treehouse lessons on front-end optimization that may touch on this.

The Wiki entry for PE https://en.wikipedia.org/wiki/Progressive_enhancement

Ferdinand Pretorius
Ferdinand Pretorius
18,705 Points

Kudos for the wiki link ( and the extra input :) )

If your using good plugins then they should have a fallback in place. If not then you would have to approach the situation by building the app with no javascript in mind. Once done you can then add javascript features. The reason for this is if someone visits your site and they don't have javascript enabled, your site will fall back to the static structure already in place.