How to use jQuery getScript ? Last Updated : 23 Apr, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The jQuery .getScript() method loads a JavaScript file from a server using the GET HTTP method and then executes it. Syntax: $.getScript(url,[callback]) Let us look at an example to understand how this method works. Example: In this example, we will use a URL to load the JavaScript file 'color.js' from the server. The file's functionality is used to add animation to our webpage. HTML <!DOCTYPE html> <html> <head> <script src= "https://code.jquery.com/jquery-3.5.0.js"> </script> </head> <body style="text-align: center"> <h2 id="heading">GeeksforGeeks</h2> <p>jQuery | getScript() method</p> <button id="button">click here</button> <script> /* The getScript method is called by passing url to load color.js and calling a function to add color animations on our page */ $.getScript( "https://code.jquery.com/color/jquery.color.js", function () { // Selecting button and adding event to it. $("#button").click(function () { $("#heading") .animate({ backgroundColor: "rgb(0, 255, 0)" }, 500); }); }); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article jQuery | Misc get() Method F faizamu19 Follow Improve Article Tags : JQuery Similar Reads jQuery getScript() Method The getScript() method in jQuery is used to run a JavaScript using AJAX HTTP GET request. Syntax: $(selector).getScript(url, success(response, status))Parameters: It contains two parameters as mentioned above and described below: url: It is a required parameter. It holds the url to whom the request 2 min read How to execute jQuery Code ? jQuery is an open-source feature-rich Javascript library that is designed for the simplification of HTML DOM Tree traversal & manipulation, event-handling & CSS animation. It is quite popular for its features like light-weight, fast, small, etc, that make it easier to use. The purpose of usi 4 min read jQuery | Misc get() Method The get() Method in jQuery is used to get the DOM element specified by the selectors. Syntax $(selector).get(index) Parameters: This method accepts single parameter index which is optional. It is used to specify which of the matching elements to get by its index number. Example 1: This example uses 1 min read How to convert jQuery to JavaScript ? JavaScript is an object orient programming language designed to make web development easier and more attractive. In most cases, JavaScript is used to create responsive, interactive elements for web pages, enhancing the user experience. jQuery is an open-source JavaScript library that simplifies the 2 min read How to Use jQuery with Node.js ? jQuery is a popular JavaScript library primarily used for client-side scripting to simplify HTML document traversal, event handling, animation, and AJAX interactions. Although jQuery is designed for the browser, you might find scenarios where you want to use it on the server side with Node.js, such 3 min read When to use Vanilla JavaScript vs jQuery ? Earlier, the websites used to be static. However, the introduction of vanilla JavaScript revolutionized the way websites used to look and function. Vanilla JS helped the developers in creating dynamic websites. Then came jQuery, a library of tools created by developers around the world, using Javasc 4 min read Like