Halve and thinly slice the onions, then thinly slice the garlic. Melt the butter with the oil in a large, heavy-based saucepan over a high heat. Tip in the onions and garlic and give them a good stir so they are glossed with butter. Sprinkle over the sugar, thyme leaves, chilli flakes if using and some salt and pepper. Give everything another really good stir and reduce the heat slightly. Cook uncovered for 40-50 minutes, stirring occasionally. The onions are ready when all their juices have evaporated, they’re really soft and sticky and smell of sugar caramelising. They should be so soft that they break when pressed against the side of the pan with a wooden spoon. Slow cooking is the secret of really soft and sticky onions, so don't rush this part.