How to use jQuery getScript ? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 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: Create Quiz Comment F faizamu19 Follow 0 Improve F faizamu19 Follow 0 Improve Article Tags : JQuery Explore jQuery Tutorial 7 min read Getting Started with jQuery 4 min read jQuery Introduction 7 min read jQuery Syntax 2 min read jQuery CDN 4 min read jQuery SelectorsJQuery Selectors 5 min read jQuery * Selector 1 min read jQuery #id Selector 1 min read jQuery .class Selector 1 min read jQuery EventsjQuery Events 4 min read jQuery bind() Method 2 min read jQuery blur() Method 1 min read jQuery change() Method 2 min read jQuery EffectsjQuery animate() Method 2 min read jQuery clearQueue() Method 2 min read jQuery delay() Method 2 min read jQuery HTML/CSSjQuery addClass() Method 2 min read jQuery after() Method 1 min read jQuery append() Method 2 min read jQuery TraversingjQuery | Traversing 4 min read jQuery add() method 1 min read jQuery addBack() Method 2 min read Like