# Load/Require/Import from Github Pages

**URL:** https://talk.observablehq.com/t/load-require-import-from-github-pages/296
**Category:** Help
**Created:** [February 11, 2018, 9:03pm UTC](https://talk.observablehq.com/t/load-require-import-from-github-pages/296 "2018-02-11T21:03:23Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)
#### Post date: [February 11, 2018, 11:30pm UTC](https://talk.observablehq.com/t/load-require-import-from-github-pages/296/2 "2018-02-11T23:30:06Z")

</div>

ES imports work, as long as you `import` a valid ES module. For example:

```auto
d3 = import("https://unpkg.com/d3-color@1.0.3/index.js?module")

```

Or, taking advantage of Observable’s built-in support for loading ES modules from [unpkg](https://unpkg.com):

```auto
d3 = import("d3-color@1")

```

So this works:

```auto
AS = import("https://backspaces.github.io/as-core/dist/AS.module.js")

```

For `require`, you need an [AMD bundle](https://github.com/amdjs/amdjs-api/blob/master/AMD.md) (or more commonly, a [UMD bundle](https://github.com/umdjs/umd)) for it to work out of the box. If you have an IIFE or a CJS bundle, you’ll need to adapt it. The pattern of catching the error and pulling out the global `AS` as you discovered is the standard pattern for loading an IIFE. But, it’s better for library authors to publish UMD bundles or ES modules for broader compatibility. Tom’s written a post on [requiring “stubborn” modules](https://beta.observablehq.com/@tmcw/requiring-modules-troubleshooting).

---

_[View the full topic](https://talk.observablehq.com/t/load-require-import-from-github-pages/296)._
