What are JavaScript and jQuery? - BEING HACKER

YOUR SECURITY IS OUR PRIORITY

Thursday, 23 November 2017

What are JavaScript and jQuery?



Introduction

The Web was a pretty boring place in its early days. Web pages were constructed from plain old HTML, so they could display information, and that was about all. Folks would click a link and then wait for a new web page to load. That was about as interactive as it got.

These days, most websites are almost as responsive as the programs on a desktop computer, reacting immediately to every mouse click. And it’s all thanks to the subjects of this book—JavaScript and its sidekick, jQuery.

What Is JavaScript?

JavaScript is a programming language that lets you supercharge your HTML with animation, interactivity, and dynamic visual effects.

JavaScript can make web pages more useful by supplying immediate feedback. For example, a JavaScript-powered shopping cart page can instantly display a total cost, with tax and shipping, the moment a visitor selects a product to buy. JavaScript can produce an error message immediately after someone attempts to submit a web form that’s missing necessary information.

JavaScript also lets you create fun, dynamic, and interactive interfaces. For example, with JavaScript, you can transform a static page of thumbnail images into an animated slideshow. Or you can do something more subtle like stuff more information on a page without making it seem crowded by organizing content into bite-size panels that visitors can access with a simple click of the mouse. Or add something useful and attractive, like pop-up tooltips that provide supplemental information for items on your web page.


What Is JavaScript?

Another one of JavaScript’s main selling points is its immediacy. It lets web pages respond instantly to actions like clicking a link, filling out a form, or merely moving the mouse around the screen. JavaScript doesn’t suffer from the frustrating delay associated with server-side programming languages like PHP, which rely on com-munication between the web browser and the web server. Because it doesn’t rely on constantly loading and reloading web pages, JavaScript lets you create web pages that feel and act more like desktop programs than web pages.

If you’ve visited Google Maps (http://maps.google.com), you’ve seen JavaScript in ac-tion. Google Maps lets you view a map of your town (or pretty much anywhere else for that matter), zoom in to get a detailed view of streets and bus stops, or zoom out to get a birds-eye view of how to get across town, the state, or the nation. While there were plenty of map sites before Google, they always required reloading multiple web pages (usually a slow process) to get to the information you wanted. Google Maps, on the other hand, works without page refreshes—it responds immediately to your choices.

The programs you create with JavaScript can range from the really simple (like pop-ping up a new browser window with a web page in it) to full-blown web applications like Google Docs (http://docs.google.com), which let you create presentations, edit documents, and create spreadsheets using your web browser with the feel of a pro-gram running directly on your computer.

A Bit of History

Invented by Netscape back in 1995, JavaScript is nearly as old as the web itself. While JavaScript is well respected today, it has a somewhat checkered past. It used to be considered a hobbyist’s programming language, used for adding less-than-useful effects such as messages that scroll across the bottom of a web browser’s status bar like a stock-ticker, or animated butterflies following mouse movements around the page. In the early days of JavaScript, it was easy to find thousands of free JavaScript programs (also called scripts) online, but many of those scripts didn’t work in all web browsers, and at times even crashed browsers.

In the early days, JavaScript also suffered from incompatibilities between the two prominent browsers, Netscape Navigator and Internet Explorer. Because Netscape and Microsoft tried to outdo each other’s browsers by adding newer and (ostensibly) better features, the two browsers often acted in very different ways, making it difficult to create JavaScript programs that worked well in both.

Note: After Netscape introduced JavaScript, Microsoft introduced jScript, their own version of JavaScript included with Internet Explorer.

Fortunately the worst of those days is nearly gone and contemporary browsers like Firefox, Safari, Chrome, Opera, and Internet Explorer 9 have standardized much of the way they handle JavaScript, making it easier to write JavaScript programs that work for most everyone. (There are still a few incompatibilities among current web browsers, so you’ll need to learn a few tricks for dealing with cross-browser problems. You’ll learn how to overcome browser incompatibilities in this book.)

In the past several years, JavaScript has undergone a rebirth, fueled by high-profile websites like Google, Yahoo, and Flickr, which use JavaScript extensively to create interactive web applications. There’s never been a better time to learn JavaScript. With the wealth of knowledge and the quality of scripts being written, you can add sophisticated interaction to your website—even if you’re a beginner.


Note: JavaScript is also known by the name ECMAScript. ECMAScript is the “official” JavaScript specifica-tion, which is developed and maintained by an international standards organization called Ecma Interna-tional: http://www.ecmascript.org/

JavaScript Is Everywhere

JavaScript isn’t just for web pages, either. It’s proven to be such a useful programming language that if you learn JavaScript you can create Yahoo Widgets and Apple’s Dashboard Widgets, write programs for the iPhone, and tap into the scriptable fea-tures of many Adobe programs like Acrobat, Photoshop, Illustrator, and Dream-weaver. In fact, Dreamweaver has always offered clever JavaScript programmers a way to add their own commands to the program.

In addition, the programming language for Flash—ActionScript—is based on Java­ Script, so if you learn the basics of JavaScript, you’ll be well prepared to learn Flash programming.

What Is jQuery?

JavaScript has one embarrassing little secret: writing it is hard. While it’s simpler than many other programming languages, JavaScript is still a programming lan-guage. And many people, including web designers, find programming difficult. To complicate matters further, different web browsers understand JavaScript differ-ently, so a program that works in, say, Chrome may be completely unresponsive in Internet Explorer 9. This common situation can cost many hours of testing on dif-ferent machines and different browsers to make sure a program works correctly for your site’s entire audience.






No comments:

Post a Comment