 JavaScript, creating great user experiences. JavaScript is a programming language that is used to add interactivity to webpages. Let's learn how JavaScript works and how it is used in a WordPress site. JavaScript is a client-side scripting language, which means that it is interpreted in the browser. To see an example of what JavaScript can do, let's take a look at the HTML from the HTML lesson and add a button which uses JavaScript to change the color of the heading element. In this example, a button element has been added to the document with the text change heading color to blue. At the bottom of the HTML document, there is a new script element. This element is used to add JavaScript to the document. A JavaScript variable called button has been created, which stores a reference to the button element by using the document query selector method and passing in the CSS selector for the button element, in this case, the word button. If JavaScript variable called heading has been created, which stores a reference to the heading element by using the document query selector method and passing in the CSS selector for the heading element, in this case, H1. An event listener has been attached to the button element. This event listener listens for the click event and when the click event is fired, it changes the color of the heading element to blue. You will notice that the JavaScript has been added to the document after the rest of the HTML elements. This is because JavaScript needs to be able to access the HTML elements in order to work. Because the browser reads the HTML document from top to bottom, adding the JavaScript at the bottom of the document ensures that the HTML elements have been loaded into the browser before the JavaScript is run. You will also notice that if you refresh the page, the heading reverts back to its original color. This is because the JavaScript can only affect the page once it's loaded in the browser, but those changes are not persistent. Like CSS, it is possible to add JavaScript to a document using an external file. This is the preferred way to add JavaScript to an HTML document. Then you would move the JavaScript into a script.js file. JavaScript is used in quite a number of places across a WordPress site. One of the biggest implementations of JavaScript is the new block editor, which is powered by a JavaScript framework called React. There are also a number of external JavaScript libraries that are used in WordPress, which you can find listed at the bottom of the credits page in the WordPress dashboard. Additionally, like with CSS, WordPress allows you the flexibility to add custom JavaScript or external JavaScript libraries to your plugins and themes. For more information about writing JavaScript, you can visit the following online resources. The section on JavaScript on the Mozilla Developer Network and the JavaScript Algorithms and Danger Structure Certification on FreeCodeCamp.