The problem is in how godot handles sprites on webGL loading all the animations for the character only when they enter your viewport I tried everything to fix it but sadly I would need to modify the compiler code to mess with that :V
my game used godot and animated sprites and we saw no such lagspikes. its not a compiler issue