In a medium saucepan, whisk together the sugar, cocoa powder, cornstarch, and salt.
In a separate bowl, whisk the egg yolks and milk until combined.
Gradually whisk the milk mixture into the saucepan with the dry ingredients until smooth.
Cook over medium heat, whisking constantly, until the mixture thickens and comes to a boil. Continue cooking for an additional 2-3 minutes to (ensure a thick consistency that will set perfectly for slicing), then remove from heat.
Stir in the butter and vanilla extract until fully melted and incorporated.
Pour the pudding into a bowl and cover with plastic wrap, pressing it directly onto the surface of the pudding to prevent a skin from forming.
Let it cool to room temperature, then refrigerate for at least 2 hours to further set.