Sticky/Fixed Header and Navigation for Debut Theme

This works great! However, I’m noticing when the page loads that there’s a brief moment where the top of the pages are hidden, and then an animation kicks in so that there’s more padding there. I think this is related to the z-index and padding of the elements, but does anyone know what I can do to stop that from happening? Perhaps load the function before the page fully loads?