# Module tips and tricks

**URL:** <https://talk.observablehq.com/t/module-tips-and-tricks/450>\
**Category:** Help\
**Created:** [March 5, 2018, 3:35pm UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450 "2018-03-05T15:35:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdwfrost](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/sdwfrost/32/139_2.png) [@sdwfrost](https://talk.observablehq.com/u/sdwfrost)\
**Post date:** [March 5, 2018, 3:35pm UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/1 "2018-03-05T15:35:28Z")

</div>

Hi all,

Are there any tips and tricks for non-UMD modules - in particular, any handy utilities to get the packages to play nicely with Observable? Here are a couple of examples:

[https://github.com/keithwhor/NtSeq/blob/master/web/ntseq.js](https://github.com/keithwhor/NtSeq/blob/master/web/ntseq.js)

[https://github.com/mattbierbaum/zombies-usa/blob/master/js/binaryheap.js](https://github.com/mattbierbaum/zombies-usa/blob/master/js/binaryheap.js)

Best,  
Simon

---

<div class="post-metadata">

**Author:** ![tom](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tom/32/2262_2.png) [@tom](https://talk.observablehq.com/u/tom)\
**Post date:** [March 5, 2018, 4:40pm UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/2 "2018-03-05T16:40:44Z")

</div>

Hey Simon,

Sure thing! These are both resolveable with one of the methods in my [stubborn modules notebook](https://beta.observablehq.com/@tmcw/requiring-modules-troubleshooting) - specifically the 'module that attaches a variable to the window but doesn’t implement UMD one - try

```
Nt = require('https://cdn.rawgit.com/keithwhor/NtSeq/master/web/ntseq.js').catch(()=>window.Nt)

```

and

```
binaryheap = require('https://cdn.rawgit.com/mattbierbaum/zombies-usa/ced65b13/js/binaryheap.js').catch(()=>window.binaryheap)
```

---

<div class="post-metadata">

**Author:** ![sdwfrost](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/sdwfrost/32/139_2.png) [@sdwfrost](https://talk.observablehq.com/u/sdwfrost)\
**Post date:** [March 5, 2018, 9:23pm UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/3 "2018-03-05T21:23:25Z")

</div>

Dear Tom,

Thanks - I’ve looked through your modules notebook, but didn’t put 2 and 2 together in the case where one isn’t globbing on to another module (as in your notebook), rather just adding something to the global namespace.

Best  
Simon

---

<div class="post-metadata">

**Author:** ![sdwfrost](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/sdwfrost/32/139_2.png) [@sdwfrost](https://talk.observablehq.com/u/sdwfrost)\
**Post date:** [March 5, 2018, 10:31pm UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/4 "2018-03-05T22:31:04Z")

</div>

Dear Tom,

What about code that isn’t wrapped up in a module of any kind? e.g.

[https://github.com/sanojian/cellauto/blob/master/dist/cellauto.js](https://github.com/sanojian/cellauto/blob/master/dist/cellauto.js)

---

<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:** [March 6, 2018, 12:11am UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/5 "2018-03-06T00:11:10Z")

</div>

Oops, this was a bug in d3-require, which is used by Observable to implement `require`! d3-require is supposed to ignore the names in asynchronous module definitions such as cellauto:

> <https://github.com/sanojian/cellauto/blob/master/dist/cellauto.js#L268-L270>

Instead, it thought that cellauto depended on various single-letter modules (“C”, “e”, “l”, ”l”, “A”, etc.). This has been fixed in [d3-require 0.6.4](https://github.com/d3/d3-require/releases/tag/v0.6.4) and will be deployed shortly to Observable.

---

<div class="post-metadata">

**Author:** ![sdwfrost](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/sdwfrost/32/139_2.png) [@sdwfrost](https://talk.observablehq.com/u/sdwfrost)\
**Post date:** [March 6, 2018, 8:51am UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/6 "2018-03-06T08:51:28Z")

</div>

Dear @mbostock @tom

Thanks! Is this also the reason I can’t load gpu.js?

[https://raw.githubusercontent.com/gpujs/gpu.js/develop/bin/gpu.js](https://raw.githubusercontent.com/gpujs/gpu.js/develop/bin/gpu.js)

Best  
Simon

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [March 6, 2018, 8:56am UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/7 "2018-03-06T08:56:59Z")

</div>

there are quite a bunch of examples with gpu.js  
`https://beta.observablehq.com/search?query=gpu`

---

<div class="post-metadata">

**Author:** ![sdwfrost](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/sdwfrost/32/139_2.png) [@sdwfrost](https://talk.observablehq.com/u/sdwfrost)\
**Post date:** [March 6, 2018, 9:08am UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/8 "2018-03-06T09:08:02Z")

</div>

Thanks @Fil - serves me right for not checking regularly! When I tried wzrd.in previously, I got an error…

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [March 6, 2018, 9:10am UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/9 "2018-03-06T09:10:48Z")

</div>

As side issue is that searching for “gpu.js” doesn’t bring results

`https://beta.observablehq.com/search?query=gpu.js` =\> 0

`https://beta.observablehq.com/search?query=gpu` =\> lots

---

<div class="post-metadata">

**Author:** ![sdwfrost](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/sdwfrost/32/139_2.png) [@sdwfrost](https://talk.observablehq.com/u/sdwfrost)\
**Post date:** [March 6, 2018, 3:11pm UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/10 "2018-03-06T15:11:45Z")

</div>

Dear @mbostock

Thanks! The following works.

```auto
CellAuto = require("https://cdn.rawgit.com/sanojian/cellauto/master/dist/cellauto.js").catch(()=>window.CellAuto)

```

---

<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:** [March 7, 2018, 9:58pm UTC](https://talk.observablehq.com/t/module-tips-and-tricks/450/11 "2018-03-07T21:58:26Z")

</div>

Glad to hear it! That `catch` block shouldn’t be necessary anymore, since cellauto.js is a valid AMD. You can say:

```auto
CellAuto = require("https://cdn.rawgit.com/sanojian/cellauto/master/dist/cellauto.js")

```
