There will be situations where we only want attributes to be applied to elements conditionally. Maybe inside of a repeater, but only specific posts. Maybe added to a header, but only when we're on specific pages, etc.
In this members-only we'll look at how we can control when custom attributes are added across our templates & pages of our site based on some conditions.
One main use case for this is when using attributes for JS libraries where the JS is searching the page for the elements which have the attributes in order to apply a specific effect or to retrieve some data. Instead of having to build multiple versions of elements, some with attributes and some without, we can instead add the attributes conditionally.