Building efficient websites with AJAX
JavaScript
In contrast, JavaScript is not restricted to isolated areas of the web page. The interpreter that is integrated with the browser executes the program and converts the whole page into a dynamically modifiable interface. To do so, scripts create or modify the HTML code on the page, modify the cascading style sheet (CSS) styles, or even draw graphics.
The scripts themselves comprise uncompiled text. In contrast to Flash development, programming in JavaScript does not require any special tools. A simple text editor is fine for a start.
Good Tools
As always, good tools make programming easier. An editor with HTML, CSS, and JavaScript support is useful. It should also be able to handle source code that mixes all three [1][2]. Chris Pederick's Firefox plugin Web Developer [3] is the obvious choice for tracing and debugging programs. It reveals bugs in HTML, CSS, and JavaScript; investigates cookies; and displays the dynamically modified HTML code, not just the original version delivered by the server.
Tables
An increasing number of applications, such as order processing and enterprise resource planning (ERP) systems use web front ends: Parts lists or other list-type overviews are the main fare.
One important feature is the user's ability to sort these lists. If the web front end is based on static HTML, the server has to regenerate the page and serve up the modified version. Of course, client-side JavaScript-based data sorting makes for a smoother process.
Figure 2 gives an example of a directory listing implemented as an HTML table. Clicking the table header sorts the table by the current column. Figure 3 shows how to do this with JavaScript. An HTML table comprises nested <tr> and <td> elements, which can be addressed via DOM [4].
The script starts by dynamically removing all the <tr> elements (i.e., the rows in the table) from the page. The rows only exist as an array in JavaScript. The JavaScript function then sorts the array on the requested column and writes the new sorting order between the empty <table> and </table> tags. Finally, the script draws an arrow, a Unicode arrow [5] character, before the label of the column on which the table is sorted.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome Fans Everywhere Rejoice for the Latest Release
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.