Most stand-up comedians write their jokes and scripts prior to the show and practice them over and over. They play to the audience as well and integrates their jokes based on who is in the crowd.
Nearly all comedians use scripts routinely. Most comedians write their own scripts, often built from personal life events. Although some improvising is normal, most comedy acts are scripted.