Brian Di Palma (2013-07-11T12:02:45.000Z)
>
> But if you try to modularize the code like:
>
> <script async>
> module "mod" {
>    export function getNode1() {
>       return node1
>    }
>    export function getNode2() {
>      return node2
>    }
> }
> </script>
> <div id='node1' />
> <div id='node2' />
>
> then it may randomly work or fail with an error depending upon who wins the
> race.  What seems like it should be a safe refactoring instead produces
> non-deterministic intermittent errors.
>

The code would be

    export function getNode2() {
      return document.getElementById("node2");
    }


Though which should be fine.
domenic at domenicdenicola.com (2013-07-13T01:12:14.661Z)
> But if you try to modularize the code like:
>
> ```html
> <script async>
> module "mod" {
>    export function getNode1() {
>       return node1
>    }
>    export function getNode2() {
>      return node2
>    }
> }
> </script>
> <div id='node1' />
> <div id='node2' />
> ```
>
> then it may randomly work or fail with an error depending upon who wins the
> race.  What seems like it should be a safe refactoring instead produces
> non-deterministic intermittent errors.
>

The code would be

```js
export function getNode2() {
  return document.getElementById("node2");
}
```

though which should be fine.