the.com/gag

A joke's job is to surprise; a gag's job is to shut you up or make you laugh trying.

means A gag is either a joke or routine built for a laugh, or a device/restraint stuffed in or tied over the mouth to stop someone speaking — the word stretches across both without much shame.

from Likely echoic in origin, imitating the choking, retching sound someone makes when something is forced into the throat — that's the physical 'gag' of stuffing a mouth to silence it, dating back to at least the 1500s. The comedic sense ('a joke, a bit') grew out of theater slang centuries later, originally meaning stage business or lines improvised by an actor, possibly because such material was 'stuffed in' to a scene unscripted. The two meanings — silence and laughter — share a root in forced, unnatural things happening at the mouth, even though they now feel like opposites.

dual meaning
stand-up joke and literal mouth-stopper, same word
etymology
from Old Norse gagg meaning to suffocate
theater origin
vaudeville slang for scripted comic bit
legal use
gag order silences speech, no punchline required
the.com · every word