elm
is null and your code never tries again later. Anyway, looping until something shows up is not a good approach. If you ensure your code runs after the code that adds the element, you shouldn’t have to loop until it shows up, it should already exist. Ensure your code runs late by enqueuing your script while listing the code that adds the element as a dependency. In the wp_enqueue_script() call, also specify that your script should be loaded in the footer.
If your intent is to hide this element why not just place the CSS for it in the Additional CSS panel of the customizer? Why use JS to hide it?
]]>I have solved it by changing the CSS at the developer’s site (it′s a connected plugin with a shortcode), so it gets its CSS from there. That′s why I was trying to make a while loop to grab it when it was loaded.
]]>