Start by thinly slicing or finely chopping yellow or red onions to caramelize onions. Heat a wide, heavy-bottomed skillet or pan over medium-low heat and add a small amount of cooking oil or butter. Add the sliced onions to the pan, spread them out in an even layer, and cook them slowly over low heat, stirring occasionally. Avoid rushing the process by increasing the heat, leading to uneven browning or burning. Once the onions are caramelized, they will have a deep golden brown color and a sweet flavor. Let them cool before using them.