Interesting performance boosting bug I just found (How is it working?)

TL;DR putting a script in a custom block makes it run faster, why?

Ok, so I was just working on a snap project and had this long rendering script I simplified by putting it in a block. Later I decided to put the script in a completely separate sprite with no custom block to make my code more organized and suddenly the project ran way slower! But then I put the script back in a block and it's normal again? It's super cool but I am curious and want to know why does it happen?

My guess is the code in the block gets compiled, which also explains why you always have to "apply" changes to a custom block before they work.

naw, no "compiling" happens (what is that even supposed to mean, some magical, mythical transformation into more performant formulations in another language? That's not how it works anyway). The reason why on some computers and in some browsers custom blocks run slightly quicker is that the scripts are hidden inside a block definition, so we (usually) don't display a "glowing halo" highlight around them, which - under some conditions (gargantuan stacks of blocks, funny graphics cards, paranoid browser settings) - takes (a little) time to compute each time the script gets run.

Interesting, thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.