Hook a script as the very last one before the closing body tag

Assuming these are scripts enqueued via wp_enqueue_script(), the absolute best solution would be to locate the registration/enqueuement of the script creating the element and simply specify it’s handle as a dependency for your script. WordPress will then ensure that yours loads after that dependency.

There are other work-arounds to ensure that your script is the absolute last, but they’re not really elegant or pragmatic. Ultimately, if the script which creates the element does not do so immediately as it loads (and it’s fairly unlikely that it does, in my experience), then your script must both come after the script in question as well as hook into the same or a latter JS event.

If you’re unable to ascertain a script hook which you can depend on, you might consider using a MutationObserver or equivalent jQuery functionality in order to simply execute your JavaScript whenever the element becomes available.

Without seeing any of your code or the code on which depends, it’s not possible to suggest which route you should take.