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: