Documentation Menu

Destroy FacePop Widget

The destroy() function completely removes the FacePop widget from your website, freeing up resources and eliminating all traces of the widget from the DOM.

Usage

To remove the FacePop widget from your website, simply call the destroy() function:

// Completely remove the FacePop widget
Answerly.FacePop.destroy();

This function requires no parameters and returns no value. Once called, the widget will be immediately removed from the DOM.

When to Use

The destroy() function is useful in several scenarios:

  • When you want to permanently remove the widget rather than just hiding it temporarily
  • When you're navigating away from a page and want to clean up resources
  • When you need to reinitialize the widget with completely different settings
  • When you're implementing conditional logic that determines whether the widget should exist on the page

Unlike hidePlayer() or hideToggle() which only change the visibility of elements, destroy() completely removes the widget and cleans up all associated resources.

Warning

This action cannot be undone. Once the destroy() function is called, you will need to reinstall and reinitialize the FacePop widget if you want to use it again.

If you only need to temporarily hide the widget, consider using hidePlayer() instead, which allows you to easily show it again later.

Example: Conditional Widget Removal

// Listen for a specific event that should trigger widget removal
document.getElementById('removeWidgetButton').addEventListener('click', function() {
  // Confirm with the user before removing
  if (confirm('Are you sure you want to remove the FacePop widget? This cannot be undone.')) {
    // Remove the widget
    Answerly.FacePop.destroy();
    
    // Update UI to reflect that the widget is no longer available
    document.getElementById('widgetControls').style.display = 'none';
    document.getElementById('widgetRemovedMessage').style.display = 'block';
  }
});