Use this code to insert an element after a referenced element in pure JS.
function insertBefore(newElement, referenceNode) {
referenceNode.parentNode.insertBefore(newElement, referenceNode.nextSibling);
}
// example usage
var newElem = document.createElement('div');
newElem.innerHTML = '<p>Im new here!</p>';
var refElem = document.querySelector('.referenceElement');
insertBefore(newElem, refElem);