In a medium saucepan (with the heat off), whisk together the sugar, cocoa powder, cornstarch, and salt. Turn the heat on low, and gradually whisk in the milk.
2/3 cup sugar, 1/4 cup cocoa powder, 3 tablespoons cornstarch, 1/4 teaspoon salt
Stir continuously while cooking the mixture over medium heat until it comes to a boil. It will take approximately 10 minutes. (See note.) Once it begins to boil, continue stirring and cooking for an additional minute. Remove it from the heat and whisk in the vanilla extract and butter.
2 tablespoons butter, 1 teaspoon vanilla extract
Transfer the pudding to a medium mixing bowl and press a piece of plastic wrap right up against the pudding to keep it from developing a skin on top. Cool in the refrigerator for at least four hours.
Top with whipped cream and chocolate shavings.
Notes
In step 2 when you are waiting for the mixture to come to a boil and thicken, it will seem like it is never going to happen and something is wrong. Then suddenly it will come together and be a great consistency.