Blog

What is: JavaScript

JavaScript is a programming language implemented in browsers to allow client side scripting on the user end. In plain English, it allows theme developers to add dynamic elements to your websites such as a slider, display alerts, buttons, popups, etc.

WordPress itself, and WordPress themes and plugins use JavaScript in combination with jQuery, Ajax and other web technologies to create faster, interactive, and better web applications.

A JavaScript file can be added with a WordPress theme or a plugin. It can be called in using wp_register_script() and wp_enqueue_script() functions. JavaScript can also be hardcoded into WordPress theme template, however this is not the best way to use JavaScript in WordPress themes.

Many WordPress themes come with a separate js directory inside them. This is where theme developers keep their JavaScript files and call them in their WordPress template files only when they need them. This approach of queuing scripts makes pages load faster and avoids loading unnecessary scripts.

WordPress also includes several JavaScript libraries which theme and plugin developers can use in their own projects. This includes jQuery, a number of jQuery plugins, Underscores, JSON for JS, and Backbone JavaScript libraries.

This post was originally published in the wpbeginner glossary.

Additional Reading