What Is A Drupal Library?

In general, in computer software, a “library” is a set of code that can be used by a program. Often, a library provides commands for functions that many different programs will need. It’s not a standalone program, but rather, it’s designed to be used by other programs.

So, in Drupal, as you might expect, a “library” is a set of code that provides functions for use by a Drupal site. However, this is also true of Drupal modulesand even of themes. So how are libraries different?

Basically, modules and themes are developed specifically for use by Drupal, while libraries are usually developed totally outside the Drupal project, for much broader use.

For instance, Drupal core relies on jQuery, a library of powerful JavaScriptfunctions. But jQuery has much wider usage than Drupal sites.

By using libraries, Drupal developers can avoid “reinventing the wheel” and focus on crafting only the specific code that someone else hasn’t already written.

How Do You Get a Library?

When you install a module that requires a library, you usually have to download the library separately. The module’s README.txt or project page should include specific instructions on where to get the library. The library won’t be on drupal.org; it’s a library, so it’s being developed elsewhere.

Pay attention to which version of the library to get. You shouldn’t always get the most recent version. You may need to get a different version depending on which version of the module you’re running.

Also make sure you don’t already have the library installed on your Drupal site. This is especially an issue with jQuery, but it can be an issue for any library that more than one module requires. If two or more modules each require incompatible versions, you have a problem.


If you use drush, check for a drush command to download the library. This is becoming common, and it saves you a bit of browsing. It should also place the library in the correct location.

Usually, the download is a ZIP file or other archive, and you will extract the archive into a directory in sites/all/libraries. Occasionally, the module will instruct you to place the library in another location.

Make sure you put the library in the correct location. If you don’t, the module won’t be able to find the library, and it won’t work.

What Language is a Drupal Library?

Most of the Drupal libraries that I see modules require are written in JavaScript. This makes sense: JavaScript works in almost any browser, and there’s no point in figuring out a “Drupal-specific” JavaScript solution when someone else has already solved your problem.

More rarely, I see libraries written in PHP. This also makes sense, since Drupal itself is written in PHP, so any server that can run Drupal will probably be able to run the library. But unlike JavaScript, which runs in the client’s web browser, PHP runs on the server, so it can pose more of a security risk. (Not that JavaScript is always risk-free.)

Choose Libraries Carefully

Whenever a module requires a library, you’ll need to review that library for security and maintenance issues, just as you would a module or theme. Of course, if the module is incredibly popular and you trust the developers, you might choose to trust the library because they do.

For examples of modules which require libraries, check out this list of modules that integrate with third-party services.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s