Prevent script from running in-game: only in the editor

I have a editor script and I want it to run only while in the editor. It's not supposed to run while playing the game.

How can I prevent this?

I've added the following to the beginning of my script:

@script ExecuteInEditMode()

However Update is still being called inside the game.

You could preface the code in Update() with an ifcheck for Application.isEditor, or if you don't even want it to happen when it's playing in the editor, use Application.isPlaying.

Checking for Application.isEditor works well. If you want the code to go away entirely in your final build you can (in C#, sorry not javascript) get the compiler to remove it, like so:

#if UNITY_EDITOR
void Update()
{
   ...
}
#endif

See the Unity docs for more info on conditional compilation.