usually a libretto is written before the music, but sometimes composers wrote some of the music first and then looked for words to go with it. composers, such as mikhail glinka, alexander serov, rimsky-korsakov, puccini, and mascagni all did this sometimes.