JavaScript and PHP Libraries Used by WordPress

By Aleksander Koko
We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now

Almost all modern software (including platforms such as WordPress) rely on third party libraries. That’s because, as developers, we don’t need to reinvent the wheel.

If I had to develop software that uses HTTP abstraction, I might use a package like Symfony HttpKernel or similar. If my software needed more than that (unlikely by the way, but let’s imagine that for our example), I could extend that package, or in the worst case, create one from scratch. Creating something from scratch isn’t a bad thing. It can actually be a good thing, since it makes you a better developer. But commonly, in most modern projects, you’ll have to depend on third party libraries (or packages). In this article we’ll take a look at the various third party JavaScript and PHP libraries used by WordPress.

List of Used Libraries in WordPress

In WordPress, third party libraries live alongside WordPress files. To better understand how files are structured in WordPress, the WordPress Codebase page will give you some answers. The wp-includes folder holds some of the libraries that are included when the application is executed. Also, in wp-admin you’ll find a second include folder that does the same as the first. In both folders you will find PHP and JavaScript files.

The third party PHP libraries are named with class-*.php (single files) or live inside their own folder. Other PHP files named class-*.php can be WordPress files (not third party). PHP files live under the wp-include or wp-admin/include folders.

JavaScript files also reside under these folders, but they are grouped in the js folder.

The CSS files are mainly jQuery or TinyMCE CSS files, found under CSS folder in the include folders.

JavaScript Libraries

Let’s start with the JavaScript libraries. WordPress uses jQuery heavily. It uses:

As you might notice, some of these libraries don’t have a link. That’s because some are them are very old and the repos don’t exist anymore. Let’s check them out one-by-one.

jQuery is a famous library, one that doesn’t need an introduction.

jQuery Masonry is plugin that makes easier to create masonry layouts like this one:

jQuery Masonry plugin

Layouts like this are a bit hard to do from scratch, jQuery Masonry makes this easy.

jQuery Hotkeys deals with shortcuts on the browser. If you’re used to tools such as StackEdit.io, you may use ‘ctrl+s’ (command+s) to save a file on gDrive or other cloud providers. The (ctrl+s) shortcut by default in your browser can be used to save a web page, using this plugin you can override these default shortcuts.

jQuery Form deals with forms and AJAX calls. If you’re curious and want to learn more about this plugin, you can check out their docs.

jQuery Color is used by WordPress for color manipulation and animation.

jQuery("#go").click(function(){
    jQuery("#block").animate({
            backgroundColor: "#abcdef"
    }, 1500 );
});

The first line selects the element with id="go" and tells the browser that it should animate the background color of the element with id="block" in 1.5 seconds.

jQuery Migrate helps you when dealing with earlier jQuery codebases. This is very important for WordPress because it is a platform that should be backwards compatible.

As a matter of fact, backwards compatibility is one of the most well known features of WordPress. On the other hand, it’s one of the problems with WordPress. WordPress was released in 2003, the PHP version that was used for that release is ancient. Today, PHP is a modern language and has borrowed many useful features from other languages. But this is another topic, one for a future article.

WordPress also uses other JavaScript libraries, not just jQuery. Here are some other popular libraries it uses:

And the list goes on and on.

The most famous from this list is TinyMCE and Backbone. TineMCE is used to compose new Posts and Pages in the WordPress dashboard.

Backbone is a front-end framework, in fact it was one of the first. It is still being used today, but loosing a lot of market share from Angular and other front-end frameworks. And yes, I’m talking to you Meteor. But don’t worry, in the JavaScript universe, frameworks (libraries) are forgotten as fast as they become popular.

PHP Libraries

The list of PHP libraries is a bit different. We saw that JavaScript was mainly influenced by jQuery and some other popular libraries. With PHP, things are different, as most of the third party libraries are just one class (file). Here’s a short list of the current third party PHP libraries:

An Open Discussion

Many of the libraries are a bit outdated. This is when discussions on topics such as architecture tend to happen. I would personally like to see Bower and Composer integration with WordPress. I would like to ask the SitePoint community about these ideas, and have an open discussion on how things can be improved with WordPress. Please leave your comments and thoughts below.

Conclusion

In this article we’ve seen the various third party libraries that WordPress uses. Knowing what WordPress uses behind the scenes, you’ll have a much better understanding on how it works. The better your understanding, the faster and smarter you’ll be able to work with WordPress. Maybe you can even work towards contributing to WordPress core. After all, this is the world of Open Source, we learn from each other and share ideas (both code and pizza!).

We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now
Login or Create Account to Comment
Login Create Account