Try wrapping the code in a function:
(() => {
const pronunciationEl = document.getElementById('pronunciation');
const pronunContent = pronunciationEl.innerText.trim();
if (pronunContent.length == 0) {
pronunciationEl.style.display = 'none';
}
})();
See: Do javascript for loops work in html templates? - #5 by hkr