To cook the onion, heat a skillet over medium heat, add butter or olive oil, then the onion, stirring often until it turns a golden color. Add the balsamic vinegar, sugar, and salt, stirring all the time. When the onion looks caramelized, add the thyme. Turn off the heat and cool. Cook the onion up to a day in advance, and keep in a tightly sealed jar in the fridge.