# Include THREE module as a global variable to be used with ES5 scripts

**URL:** <https://discourse.threejs.org/t/include-three-module-as-a-global-variable-to-be-used-with-es5-scripts/16762>\
**Category:** Questions\
**Tags:** modules\
**Created:** [July 3, 2020, 10:02pm UTC](https://discourse.threejs.org/t/include-three-module-as-a-global-variable-to-be-used-with-es5-scripts/16762 "2020-07-03T22:02:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedeMarino](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fedemarino/32/51061_2.png) [@fedeMarino](https://discourse.threejs.org/u/fedeMarino)\
**Post date:** [July 3, 2020, 10:02pm UTC](https://discourse.threejs.org/t/include-three-module-as-a-global-variable-to-be-used-with-es5-scripts/16762/1 "2020-07-03T22:02:20Z")

</div>

Hi, I have a three.js app made with version \< 100.  
I want to upgrade it to the latest release but I have many functions and classes that are included  
through a script TAG, in HTML, that are not modules and expect THREE to exist.

Is there a simple way to include the Three.js module as the old way, in a global THREE variable?  
I tried

```
 <script type="module">
  // part 1
 import * as THREE from './../node_modules/three/build/three.module.js';
   window.THREE=THREE;
<script>

<script>
       // part 2
      var a=new THREE.Scene();
<script>

```

But If I step into the code part 2 seems to execute before part 1

---

<div class="post-metadata">

**Author:** ![dyarosla](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dyarosla/32/5468_2.png) [@dyarosla](https://discourse.threejs.org/u/dyarosla)\
**Post date:** [July 4, 2020, 2:20am UTC](https://discourse.threejs.org/t/include-three-module-as-a-global-variable-to-be-used-with-es5-scripts/16762/2 "2020-07-04T02:20:30Z")

</div>

You can use the `defer` attribute for those scripts that need to be run after the modules are loaded.

`<script src="abc.js" defer></script>`

[https://www.w3schools.com/tags/att\_script\_defer.asp](https://www.w3schools.com/tags/att_script_defer.asp)

When you save out, in the module tag  
`window.THREE = THREE;`  
you can then use it in the later deferred script with  
`var THREE = window.THREE;`  
and proceed as normal.
