We’re long past the days where a few lines of JavaScript in a single .js file cut the mustard—modern web applications can involve thousands of lines over hundreds of files, and WordPress themes and plugins are heading in that direction fast. You can make your codebase much easier to maintain and expand by breaking your scripts up into modules, encapsulating different logical units in their own files. We will learn several ways to modularize your code, with a focus on AMD and Require.js. All these files can take a while to load, so we’ll also look at how to use a build tool to author your code in dozens of files without compromising performance for your end users. To close, we’ll take a quick peek into the future to discover the native module syntax coming in the next version of JavaScript!