What Is a Togle?

A toggle is a switch that has two positions, on and off. The word has many meanings in our everyday lives — we toggle between screens as we video chat with two friends at once or flip between the news and sports on TV.

In the world of software development, toggles are used to enable features or to disable them. Savvy teams view their feature toggle inventory as something that comes with a carrying cost so they work to keep it at a manageable level. This is accomplished by ensuring that toggles are not being used for the wrong purposes (e.g., using a toggle to download content instead of a button) and by being proactive about removing toggles that are no longer needed (e.g., putting “expiration dates” on toggles that will fail a test or even refuse to start the application if the toggle is still in use after the expiration date).

One way of managing the configuration of a toggle is to hardcode it into the code via a preprocessor’s #ifdef feature or other code commenting method. This approach is relatively simple but does not allow for dynamic re-configuration of the toggle at runtime. This limitation becomes limiting when the toggle is used to perform experiments (e.g., A/B testing) where we would like to be able to exercise both code paths and compare the results.

This is why savvy teams often choose to move toggle configuration out of the static files and into some type of centralized store, often an existing application DB. In order to facilitate re-configuration of the toggle at scale it is usually accompanied by some sort of admin UI which enables developers, testers and product managers to view and modify its configuration.

The ability to easily hide or expose content on a page is very important to users. Visibility toggles are commonly used to do this. However, be careful when using this type of toggle because it is possible to mislead users by telling them that turning a toggle on will cause the content to be downloaded. This is a misuse of toggles because downloading content is a one-time action that does not continue after the toggle is turned off.

Another common use for toggles is to enable or disable the display of certain sections of an article. These can be things such as navigation bars, article links or map previews. Using a visibility toggle is an effective way to do this but be aware that people who know how to inspect source code can still see hidden content if the toggle is turned on. The best way to avoid this is to use a different solution such as subscriber group containers or hidden comments.