How to remove component that is empty on dynamic page?

I found a solution for my issue. I was looking at it more from an SEO perspective, as the boxes I was hiding were sometimes headers. If the field was empty, it would collapse it properly but the code would then show an empty header tag (not ideal). Therefore, I just changed the html to be empty. The Wix div tag for the collapsed component is still there, but thats not a concern.

	const header = $w('#text248').text; 
	if (header === '') { 
		$w('#text248').html = ""; 
		$w('#text248').collapse(); 
	}