Cook over low heat, stirring until the sugar is completely dissolved.
Add the butter and continue cooking until the mixture thickens (about 30–40 minutes), stirring frequently.
Once it has a syrupy texture, remove from heat.
Add vanilla if desired.
Pour into a glass jar and let cool.