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.
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?
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.