You’ll need to use a Custom Event for this (see Custom Events above). What we’re doing is waiting until the section loader has loaded, then checking to see if there are any blocks, and if not, hiding the block with some inline CSS, display:none.
Place this code in your Site Header Code Injection area.
<!-- Hide Empty Section Loaders -->
<script>
document.addEventListener('wmSectionLoader:loaded', ({detail}) => {
const loaderBlock = detail.block;
const hasBlocks = loaderBlock.querySelectorAll('.sqs-block');
const isGallery = loaderBlock.querySelectorAll('.gallery-section');
const isListSection = loaderBlock.querySelectorAll('.user-items-list-section');
if (!hasBlocks.length && !isListSection && !isGallery) {
loaderBlock.closest('.sqs-block').style.display = 'none'
}
})
</script>