Cetanu Posted August 4, 2009 Share Posted August 4, 2009 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! Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted August 4, 2009 Share Posted August 4, 2009 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! 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. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 4, 2009 Share Posted August 4, 2009 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. Quote Link to comment Share on other sites More sharing options...
Cetanu Posted August 5, 2009 Author Share Posted August 5, 2009 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. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted August 5, 2009 Share Posted August 5, 2009 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. Quote Link to comment Share on other sites More sharing options...
haku Posted August 5, 2009 Share Posted August 5, 2009 What they said. Javascript used properly = excellent tool, makes sites much better Javascript used improperly = horrible tool, wrecks everything Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted August 5, 2009 Share Posted August 5, 2009 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. Quote Link to comment Share on other sites More sharing options...
Cetanu Posted August 5, 2009 Author Share Posted August 5, 2009 Okay, thanks for all your help, guys. NOW I understand why I got reprimanded for using JS for site navigation. Quote Link to comment Share on other sites More sharing options...
Maq Posted August 6, 2009 Share Posted August 6, 2009 A bit off-topic but, take a look at GWT and the canvas element for HTML5. These are both going to be pretty big in the future. All heavily based on JS. Quote Link to comment Share on other sites More sharing options...
Cetanu Posted August 7, 2009 Author Share Posted August 7, 2009 I've never heard of them.... >.> <.< Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.