Jump to content

Is JS Bad?


Cetanu

Recommended Posts

Well, lot's of people say, "DON'T USE JAVASCRIPT!!!!!"

And when I ask why they say that people can disable Javascript...but according to some statistic I found only about 4.45% of people disable JavaScript, and it seems pretty handy for some things.

 

Any feelings, thoughts, etc? I need help!  :P

Link to comment
Share on other sites

Well, lot's of people say, "DON'T USE JAVASCRIPT!!!!!"

And when I ask why they say that people can disable Javascript...but according to some statistic I found only about 4.45% of people disable JavaScript, and it seems pretty handy for some things.

 

Any feelings, thoughts, etc? I need help!  :P

 

JavaScript gets a bad rap for a variety of reasons, the biggest of which are from the early days of the internet when JavaScript was widely misused.  Script errors - many of which broke web pages (or worse!) - were common, as was the tendency to bury the user under mounds of popup windows.  And, of course, there were security issues tied to it back then, too.  That it behaves differently than other web languages makes it a target of many wannabe developers even today as well.

 

As the web matured, so did JavaScript and those that coded in it.  Today, it's a cornerstone technology of the web.  Many interactive web apps - like the majority of what Google does (GMail, Maps, etc) - are written with JavaScript.

 

That said, you shouldn't use JavaScript for mission-critical tasks like form validation because it can be turned off.  JavaScript exists primarily as a way to enhance websites.  If used in that manner, it can be very useful.

 

If you want to be a professional, you'll need to learn some JavaScript at some point.  It's too widespread to avoid in the modern web.  But no, JavaScript is not inherently bad.

Link to comment
Share on other sites

That said, you shouldn't use JavaScript for mission-critical tasks like form validation because it can be turned off.  JavaScript exists primarily as a way to enhance websites.  If used in that manner, it can be very useful.

 

Exactly! You should (in my opinion) develop your site without any javascript to have a functioning site. Then add "unobstrusive" javascript where appropriate to enhance the user experience. Here's an example to illustrate.

 

Let's say you need the user to enter their state and city from predefined lists. You have a list of states and lists of cities for each state. You wouldn't want the user to enter  a city and state combination that doesn't exist.

 

For the "non-javascript" implementation you could have the state and city lists populated with all possible values and do the validation server-side. If the user selects a combination that is not valid redisplay the form for them to make another selection. It works, but is not exactly user friendly.

 

So, you decide to implement some javascript on top of the non-js implementation. You could use strait JS or AJAX to dynamically populate the city list as the user changes the selected state so the user can't make an invalid selection. However, you would still keep the server-side validation in case the user has JS turned off.

 

The "unobtrusive" part would come into play on page load. By default you would populate all values in the lists to accomodate the non JS users. But youwould implement an onload function to automatically repopulate the city list based upon the default state.

Link to comment
Share on other sites

Okay. Thanks for clearing this up.

 

When I had the original version of my site is used JS for the menu, but when I posted it up here for critiquing I was told that I shouldn't use JavaScript a lot at all...so I got confused. But now I understand more. :)

Link to comment
Share on other sites

Okay. Thanks for clearing this up.

 

When I had the original version of my site is used JS for the menu, but when I posted it up here for critiquing I was told that I shouldn't use JavaScript a lot at all...so I got confused. But now I understand more. :)

 

Ah, yeah, that sort of thing would definitely draw criticism here.  A site should be fully functional without JavaScript.  The JS should be used to enhance the existing, underlying site.

 

To use an analogy, a site is like a house.  The HTML is the boring, but critical stuff.  The foundation, the bathroom(s) and kitchen.  The CSS is the floor plan and materials.  The fancy oak and the marble tile.  The JavaScript is the cool stuff - the HDTV and XBOX 360.  It delivers the wow factor, but you can't rely on it for the essentials (to completely beat the analogy into the ground, the HDTV certainly won't keep you warm in winter, nor keep food from spoiling).

 

As long as you view JavaScript as an extra treat rather than a critical component, you'll be fine.

Link to comment
Share on other sites

It depends on your target audience and how you're using the JavaScript.

 

If you're using JavaScript to open multiple browser windows and bounce them around all over the screen, then you're using JavaScript to be a nuisance.  Historically this is one of the things that has given JavaScript a bad reputation.

 

If you want your site to be as widely accessible as possible and it won't work without JavaScript, then you've used JavaScript improperly.  JavaScript should only be used to enhance an already functional site when you want to target the widest possible audience.

 

If you are designing a commercial product or a custom product, for example for a kiosk, then it's fine if you're product requires JavaScript.  Often times with such products there exist time or money constraints that do not allow you to make it work and then make it better with JavaScript.  In those situations I typically decide to make it cool and make JavaScript a requirement for the product's use.

 

So, like almost everything else in life, the answer to your question is:

Yes.  No.  It depends.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.