Prevent duplicate additions of HTML markup added in a JavaScript function

The bug is that https://gitlab.com/agaric/drupal/checkboxesjs was adding more checkboxes every time autosave ran!

drupal 8 get ID of checkboxes container jquery ensure dom updated before next method operates jquery ensure each runs after previous each drupal 8 #pre_render

Ancient answers… https://forum.jquery.com/topic/waiting-for-a-dom-element-to-become-available

No this can’t be a good idea. https://swizec.com/blog/how-to-properly-wait-for-dom-elements-to-show-up-in-modern-browsers/swizec/6663

https://www.drupal.org/docs/develop/standards/javascript/javascript-coding-standards#indenting

This was fixed with