"yolo" was written by all performers of the track, the lonely island, adam levine and kendrick lamar. also credited for songwriting are rhiannon bryan and rhydian davies, members of the welsh alternative rock band the joy formidable, whose 2011 single "whirring" is sampled throughout the song. the song was produced by needlz, who had previously worked with lupe fiasco and 50 cent. the song was originally planned to feature katy perry, but two weeks before the song was released, this was changed to feature maroon 5's adam levine, who was hosting "saturday night live" the same night, and kendrick lamar, who had previously requested nbc to put him in a "saturday night live" digital short or one of its many skits. the premiere of the song on "snl" also marked the temporary return of lonely island frontman andy samberg, who had left "saturday night live" the year before, but managed to get an appearance of the lonely island for the premiere of the song.