If you’ve worked on the Web at all, you’ve probably heard about JavaScript. JavaScript is a scaled-down programming language based on Java and streamlined for the Web. But in a sea of Web programming languages, does JavaScript really stand out? Actually, yes. JavaScript does something that none of the other major languages can do.
The big difference between JavaScript and other Web programming languages is that JavaScript is a client-side Web language, meaning that it runs after it loads on the user’s computer rather than on the server before it gets sent to the user. PHP, Visual Basic (ASP or ASP.NET), and C# (ASP.NET) are server-side languages, meaning the code is run on the server before the web page is even sent to the user. Because it runs after the page is loaded, JavaScript allows us to make changes to a page without reloading it—making JavaScript the key element to interactive web pages.
Still not a believer? Go to a web page with a lot of images and then paste this into your address bar and press enter:
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName(”img”); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position=’absolute’; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+”px”; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+”px”}R++}setInterval(’A()’,5); void(0);
It’s magic! If you don’t understand all that stuff I said above about a client-side programming language, I’ll tell you that JavaScript is magic and those who can write it are powerful wizards.
The truly sad news is that some JavaScript wizards can use their powers for evil rather than good. You know those alert boxes that make you click OK before you can continue? That’s JavaScript. Pop-ups and pop-unders? Re-sizing your browser window? Rick Astley? All JavaScript. For this reason, some people disable JavaScript entirely in their browsers. The last global estimate was that somewhere around 6% of Internet users have JavaScript disabled.
But JavaScript can do useful things too. JavaScript can make changes to an HTML form so that you don’t have to load three pages just to fill out a single form. JavaScript also gives web designers a way to make links in a web page that will send you back to whatever page you came from, send the page to a printer, or add a web page to your favorites list automatically. Dynamic Drive has some crazy JavaScripts for menus, calendars, text scrollers, and tons of other things. Also, check out this page to see the true power of JavaScript.
So before you discount JavaScript as a means of cheap tricks and cyber hi-jinks, remember that it has many valid (and valuable) uses! JavaScript is a designer’s friend, and it allows us to make the Web a more dynamic place. So here’s to you, JavaScript! May you live long and grow in features, and may we find ways to block your more annoying uses.
