Back to Browse

Massive strides in optimization

229 views
May 7, 2026
2:40

There was something Kyuu Desperation said that kept itching the back of my mind, he said: "functions are slower than JS" which at the time made zero sense since functions are parsed into native C++ and ran directly into Minecraft's engine while JS is as slow as websites. So surely using JS and functions interchangeably brings the flexibility and power of JS while having the speed of C++ right? He had 10 years experience in development so I didn't just dismiss it entirely, it remained at the back of my head for a LONG while. Then when my ADHD kicked in and I tested this... I used the profiler and it turns out running a single line of entity.runCommand() takes 0.400ms on ONE command. I WAS SOOO WRONG, I WAS THE BOTTLE NECK THE WHOLE TIME. then I rewrote a function using just pure JS to see if theres was even a substantial improvement to warrant rewriting everything. AND IT WAS. That singular function n shit went from 1.800 ms cpu time to less than 0.100 ms. JESUS CHRIST THANK YOU GOD & MOJANG FOR BESTOWING JS INTO MINECRAFT. So anyway I rewrote all my scripts in the span of 2 weeks, almost all of it needed me to step off the computer and ponder in the shower for a while thinking about how I'll achieve the same functionality with every function as before but in pure JS. I got it down for lots of smaller functions while others I just removed entirely cus their minimum performance cost was too much for my standards now. For larger functions, I had to bash my head against the wall in 8 different sessions cus the solutions I came up with from the previous 7 didn't work. It was sooo worth it, cus before I can barely run 5 dragons, now it doesn't even complain when I run 60 at the same time. I've also removed the start up lag which spiked the cpu usage by 86ms, its now zero ms cus I found out conditional import is the one doing all 86ms. static imports are so commonly used but I didn't know that until I looked into lots of professionally made addons and saw none of them used conditional imports at all and they had 10 times more code to import than my addon yet they still had zero lag. also shout out to u/DizzyGlizzy029, u/scissorsgrinder and @Jake-gl1cz for being there while I was down, you a real one Edit on May 7, 2026: this is the same phone that was barely able to run a single dragon with fancy graphics on and the phone heating up hard. it didnt even break a sweat with this many dragons after the optimizations in place.

Download

0 formats

No download links available.

Massive strides in optimization | NatokHD