So before actually discovering that there’s a built-in function to remove/load a widget, we are doing it using a CSS class:
const hubspot = document.getElementById('hubspot-messages-iframe-container');
if (hubspot && role === 'admin') {
hubspot.classList.add('hide-hubspot');
}
.hide-hubspot {
visibility: hidden;
height: 0 !important;
width: 0 !important;
display: none !important;
}
We only do this if the authenticated user on our site is an admin. If not or unauthenticated, we remove that class.
For some reason, the widget came back and we’re not able to reproduce how it happened. I’m thinking it’s because there’s some code in the hubspot embed script that reloads the widget but not sure when/where does it happen?
I am about to open a pull request that replaces our own hide/show class to using the built-in APIs but I’d be happy to know what’s the possible cause that let the widget be visible again. Thank you!