Skip to content

Effects

Some ads leave side effects on the page, such as style additions or elements rendered outside of the placement. The Effects system in Htag helps you clean up these side effects when ads are removed.

The Effects system provides a way to manage and clean up side effects created by ads. When an ad creates elements, styles, or other changes outside its designated placement, these changes need to be properly removed when the ad is no longer displayed.

Tags are a powerful feature that allow for selective cleanup. Each effect can be associated with one or more tags, which are used to identify when the effect should be cleaned up.

NameDescription
waiting-for-element:{element ID}The tag is used when it’s necessary to wait for an element or its specific state, for example, the completion of hydration.
yaleo:parent-document-styles-{random string}Used to track and clean up styles injected into the parent document by Yaleo apps.

Effects are automatically cleaned up in the following situations:

  1. When a specific ad is refreshed (cleans up effects tagged with that ad’s ID)
  2. During page transitions (cleans up effects tagged with htag:refresh-page)
  3. When explicitly triggered via the clearEffects API

This ensures that side effects don’t persist longer than they should, preventing memory leaks and visual artifacts.