My Profile

Friday, January 21, 2011

Overcoming JavaScript's Limitations


Although the JavaScript language has many features, it's far from perfect and has many limitations. Some of these may be fixed as the language matures, but others may never be-because JavaScript is meant to be an easily understood scripting language, some features just don't belong.

Luckily, there are ways around most of the limitations in JavaScript. These include programming a solution "the long way," and combining JavaScript with other powerful languages, such as Java, CGI, and SSI.

Missing Features


JavaScript is still being developed, so there are still a few missing features. These might be fixed by a future version, but some may never be fixed. The following sections describe some of the most important features that are missing from JavaScript.

Working with Entire HTML Pages


A convenient use for JavaScript is to make a Web page interactive-for example, displaying the current time or date or including information that depends on the user's input. Unfortunately, there is no way for a JavaScript program to replace part of the currently loaded HTML page. You can reload the page with different contents, but you can't change the text on a page in place.

There are some elements of the page you can change: the images, and anything in a form element. You can also display the information you need to change in a separate frame. You can also get around this by using Java, which has no such limitations.

Lack of Network Communication


JavaScript has no facilities for communicating between the Web browser and the HTTP server. This means that although you can use JavaScript to manipulate data the user enters in a form, you can't send the resulting data back to the server. You can combine JavaScript with another Web language to solve this problem; CGI is the easiest way to do this.

Tip
Netscape has created a server-side version of JavaScript called Livewire. Unfortunately, it works only with Netscape server software. 


Limited Graphics and Multimedia Capabilities


JavaScript is a scripting language, so you should hardly expect it to be a multimedia powerhouse. You can include graphics in a Web page and use JavaScript to specify which ones, but you cannot create graphics-for example, draw a graph. Currently, Java is the best solution when you need to do this.

Limited Size of Scripts


The early implementations of JavaScript (in Netscape Navigator) required that the scripts you use for a Web page be included in the HTML for that page. This means that there was a practical limitation of about 32K for the page and all scripts, because the browser must download the entire page before executing the script.
The JavaScript specification includes an SRC attribute to the <SCRIPT> tag, and this is supported by Netscape's latest version. This will enable you to embed a JavaScript script in the page, similar to an image. This should make much larger scripts practical. To use it, follow these steps:
  1. Place the JavaScript program in a file with a .js extension, such as program.js.
  2. Include the <SCRIPT> tag to refer to it, such as <SCRIPT SRC="program.js">.
  3. Be sure the script and the JavaScript file are in the same directory on the Web server.

Limited Speed


The current implementation of JavaScript is a bit slow. Any complex calculation or manipulation of HTML tends to run at a slow creep. I assume that Netscape is aware of this and will improve the speed in future versions. Unfortunately, complex Java applets also run quite slowly, so there is no clear solution at this time.
Don't let this scare you away from JavaScript-many of the most powerful things you can do with JavaScript are simple and execute incredibly fast. It's only complex applications that suffer from this limitation. 

----------------------------------------------------------

** If you like this post please like our page in facebook

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More