Heads up! This blog post hasn't been updated in over 2 years. CodePen is an ever changing place, so if this post references features, you're probably better off checking the docs. Get in touch with support if you have further questions.

RequireJS is…

… a JavaScript file and module loader. It is optimized for in-browser use

You can use it in CodePen. It actually works pretty well with our Asset Hosting feature.

You set a baseURL of where the assets are hosted, which could be anywhere, but is specifically…


…if you’re using our Asset Hosting.

Then you describe the different packages by name, subfolder, and file name. The subfolder is the only weird thing. It will be your user ID, which you can see in any uploaded asset file path, like:


My user ID there is “3”, so that’s what you would put for location when defining a package.

Here’s a complete working example:

See the Pen Using RequireJS in Pens by Chris Coyier (@chriscoyier) on CodePen.