How to control GTM Tags for jQuery to be loaded first?

One method is to push an event to dataLayer when the popup is loaded.

the other method is you can fire your code and gtm.dom or gtm.load(when the page is completely loaded)

here is an article that will help you understand GTM triggers

if you are using this trigger for a click/form you can simply use the data validation offered by these trigger

enable check both options in check validation

set the time you would like to wait

you would have to create a variable for the element you are waiting and set the rule to match the value you are looking for