Scripting is used to automate tasks on a website. It can respond to any specific event, like button clicks, scrolling, and form submission. It can also be used to generate dynamic content. and JavaScript is a widely used scripting language. In this article, we will learn about types of scripting, their features, benefits, applications, and steps to use them.
Types of scripting
There are two types of scripting:
- Client-side scripting (browser scripting)
- Server-Side Scripting
1. Client-side scripting (Browser Scripting)
Client-side scripting refers to the scripts that run on the user's web browser. and JavaScript is the most common language for scripting. It is mostly supported by all browsers, and it allows dynamic scripting. It can handle user interactions like button clicks, hovers, and form submissions, and it can also reduce the load on the server as processing happens on the client side. By using client-side scripting, you can also validate the form field, access the DOM, and manipulate it to dynamically change its content.
2. Server-side scripting
Server-side scripting refers to scripts that run on the web server. and languages such as PHP, Python, Java, and Node. JS is used for server-side scripting. In server-side scripting, the script is executed before it is sent to the browser. It can handle tasks that require a database, file system, and any other server resources securely. It creates dynamic content based on user requests. You can also create an API by using server-side scripting.
Features of Browser Scripting
- By using Document Object Model (DOM) you can dynamically change the content of a web page.
- Event Handling allows you to respond to events like button clicks, form submitting, etc..
- By using Asynchronous JavaScript XM (AJAX) you can dynamically change the content without reloading the page.
- It supports client-side storage like cookies and local storage.
Benefits of Browser Scripting
- It is supported by every browser.
- You can automate tasks like form filling, Data extraction, etc.
- By using AJAX you can dynamically display content without reloading to web page.
- It allows access to browser storage like local storage and cookies.
- You can respond to any event.
- By using DOM you can Dynamically change the content and structure of a web page.
Application of Scripting
- It can be used with other Languages.
- You can make an HTTP request to the server.
- You can automate tasks.
- It can be used to access DOM and dynamically change content.
- It provides a storage facility.
- You can respond to any specific events like button click, scroll, etc.
- It can be used to extract data from server response.
Steps to use Scripting
- Choose a Scripting Language. Ex, JavaScript
- Use any code editor for writing your script. Ex, Notepad, VS Code, Sublime Text etc..
- Learn How to manipulate a DOM and Event Handling.
- Run your Script on Any Browser.
Example
In this example we are change the text GeeksForGeeks on calling a function by button click event. and after 2 second it is alerting a message.
HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>GeeksForGeeks</title> </head> <body> <h1>GeeksForGeeks | Browser Scripting</h1> <button onclick="showtext()">Say Hello</button> <h2 id="text">GeeksForGeeks</h2> <!-- Script tag is used to write Script --> <script> // JavaScript code starts here // This Function is called when you click on "Say Hello" button. const showtext = () => { // Get the element with the id 'text' let text = document.getElementById('text') // Change the text content of the 'text' element text.innerText = "Hello" // Set a timeout to display an alert after 2 seconds setTimeout(() => { alert("Text has been changed") }, 2000) } </script> </body> </html>
Output
Conclusion
Scripting plays an vital role to guiding browser on how to respond to events. And JavaScript is the popular and broadly used language for scripting. By using scripting you can dynamically change content by using DOM, event handling and AJAX.
Similar Reads
What is Scripted Testing?
Testing practices and their related approaches can be divided into different forms according to needs and specific contexts. Among these, scripted testing is one of the common testing methodologies that is used by most organizations. This article focuses on scripted testing, when and where it is use
7 min read
What is JavaScript?
JavaScript is a powerful and flexible programming language for the web that is widely used to make websites interactive and dynamic. JavaScript can also able to change or update HTML and CSS dynamically. JavaScript can also run on servers using tools like Node.js, allowing developers to build entire
6 min read
What are Scripting Languages?
All the scripting languages are programming languages. It is a type of programming language in which there is no compilation and the execution takes place line by line. Generally, a programming language would be first compiled and then executed, but in a scripting language, the program will be execu
5 min read
What is Malicious Script
Malicious scripts are small pieces of malicious code that hackers secretly inject into legitimate websites, applications, or even ads. They may appear to be part of an ordinary webpage but quietly operate in the background to steal confidential information, redirect users to imposter pages, or insta
6 min read
What is ScriptManagerProxy Control ?
Creating interactive and dynamic web applications in the field of web development sometimes entails adding client-side scripting languages such as JavaScript. ScriptManagerProxy is a powerful tool provided by ASP.NET, a popular framework for developing web applications, that facilitates the manageme
3 min read
What is a Test Script in Software Testing?
Active software projects are constantly changing - pages are being redesigned, user information is changing, and new functionality is being added. For it to work overtime, testers must make a constant effort to update the documents to match the new product. This can take a long time to test. Another
6 min read
Bash Scripting - Functions
A Bash script is a plain text file. This file contains different commands for step-by-step execution. These commands can be written directly into the command line but from a reusability perspective, it is useful to store all of the inter-related commands for a specific task in a single file. We can
6 min read
What is Security Automation?
Security automation is revolutionizing the field of cybersecurity, providing businesses with advanced tools to enhance their defenses against cyber threats. Security automation uses technology to automate cybersecurity which speeds up threat detection, incident response, and vulnerability management
8 min read
Shell Scripting - Decision Making
A Shell script is a plain text file. This file contains different commands for step-by-step execution. These commands can be written directly into the command line but from a re-usability perceptive it is useful to store all of the inter-related commands for a specific task in a single file. We can
7 min read
Shell Scripting - Talk Command
The use of Shell scripting can simplify repetitive tasks and enable more complex operations with minimal code. Shell commands vary in syntax, with "talk" being a command to facilitate communication among users within the same network. Proper knowledge of the shell, OS, and available commands is nece
6 min read