what is the etymology of the term "gag" for a joke

"gag" is a synonym for "joke", it's not specific to comic strips.

etymonline.com has this derivation of this sense of the word:

"a joke," 1863, especially a practical joke, probably related to theatrical sense of "matter interpolated in a written piece by the actor" (1847); or from the sense "made-up story" (1805); or from slang verbal sense of "to deceive, take in with talk" (1777), all of which perhaps are from gag (v.) on the notion of "to stuff, fill." Gagster "comedian" is by 1932.

So it doesn't have to do with not being able to breathe, but the way the joke is stuffed into a play, similar to the way a gag is stuffed into a person's mouth.