# How to load a local js file into Observable?

**URL:** <https://talk.observablehq.com/t/how-to-load-a-local-js-file-into-observable/3219>\
**Category:** Uncategorized\
**Created:** [May 5, 2020, 4:43pm UTC](https://talk.observablehq.com/t/how-to-load-a-local-js-file-into-observable/3219 "2020-05-05T16:43:02Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [May 5, 2020, 6:27pm UTC](https://talk.observablehq.com/t/how-to-load-a-local-js-file-into-observable/3219/5 "2020-05-05T18:27:17Z")

</div>

If you want to require a file attachment, it’s:

```auto
foo = require(await FileAttachment("foo.js").url())

```

This assumes that your file (foo.js) is compatible with AMD ([d3-require](https://github.com/d3/d3-require)). If you want to load a standard ES module instead, you can use dynamic import:

```auto
foo = import(await FileAttachment("foo.js").url())

```

---

_[View the full topic](https://talk.observablehq.com/t/how-to-load-a-local-js-file-into-observable/3219)._
