Build/three.js depreciation?

I’m using three.js in a small website.
To include it I use

<script src=""></script>

I get this warning now
three.js:1 Scripts “build/three.js” and “build/three.min.js” are deprecated with r150+, and will be removed with r160.

I have read the docs which give a couple of alternatives going forward, but they are more complicated! These new options involve npm etc, and I don’t want to over-think it, but when I’ve tried VS code and offline development before I got stuck!
Currently I can just edit my code on my server. No complicated package managers required!

So my question is after this is depreciated, will it be more complex to include three.js?
Will the older three.js sources still be around which I can still link directly?

You can fetch any previous source from quite a few CDNs, ex.: (CDNs usually also allow you to specify which version you’d like to use, so your website doesn’t accidentally break with a new release of three.)

1 Like

You can still use the “esm” (module) builds, even without a package manager or build tools. You’ll just have to configure importMaps and maybe refactor some of your code.

Without going into too much detail, it is most likely still working fine. Although I’m not 100% sure if modules can be loaded over the file protocol :thinking:

1 Like

If you want to have everything simply on your server, the variant I use for my collection might be interesting for you.

See * and there Module usage
( )

1 Like

I still write my three.js programs on an old HTML editor.

Here is a typical sequence of instructions that I use:

<script type="importmap">
		"imports": {
			"three": "", 
			"three/addons/": ""

<script type="module">

import * as THREE from "three";
import {OrbitControls} from "three/addons/controls/OrbitControls.js";

This will switch you to using modules.

And, as noted, if you want to use a specific version of three.js, you can designate that in the import section (the example above references r153). You can check the website to get the proper reference to the versions available.

The other advantage is that, as long as you are not loading something, you can run this kind of program locally. (Or if you want to load objects or textures, you can load examples from the three.js website - or from if they are available.)


Will these import statements work in an index.html file? or is a Nodejs command?

Im a bit confused what this importmap thing is too?

Yes, they work with an index.html file. The section between <script type = "module"> and </script> is where you are inserting the three.js code. Node.js is not required. Just an html editor.

The importmap thing is now the standard three.js protocol, used in all their demo program. If you want a more detailed explanation, you can find this topic discussed in several places on this website.

1 Like