Underscore.js in a Theme or Module for Drupal 8, 9

Last updated
Up-to-date with minor version

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Alternate resources

See the related change record for information on how to update your Underscore code with vanilla JS.

Underscore.js is a very small library which provides several utility functions and helpers to make working with JavaScript a little bit easier. In this tutorial we'll take a look at a part of the library, learn where the full library is documented, and see how we can make use of Underscore.js in a custom block on our Drupal site.