How to remove component that is empty on dynamic page?

Perhaps consider assigning a URL to the HTML component (through your code) if the src is null to avoid the error. Since it is hidden, the URL used shouldn’t matter. That is if you are concerned about the error