It played like a well-rehearsed stand-up routine.

“Let’s say you’re on the campaign trail . . .,” the audience member begins.

“I have been, yeah, uh-huh,” Elizabeth Warren nods, affecting exhaustion. The crowd at the televised CNN town hall titters with laughter.

The man asking the question continues: “A supporter approaches you and says, ‘Senator, I am old-fashioned, and my faith teaches me that marriage is between one man and one woman.’ What is your response?”

“Well, I’m going to assume it’s a guy who said that,” parries Warren, the senator from Massachusetts and presidential candidate. (More chuckles.) “And I’m going to say: ‘Then just marry one woman! I’m cool with that!’ ”

Laughter and whooping fills the room. Warren leaves space for the laugh, coolly shrugging and cocking her head and resting for a few beats before twisting the knife:

“Assuming you can find one.”

Uproarious laughter and applause. Warren, deadpan but victorious, turns and strolls back toward center stage.

Forget that the joke had been teed up — the person asking the question, Morgan Cox, was chair of the board of directors at the Human Rights Campaign and a donor to Warren’s 2018 Senate campaign — it was a well-performed series of zingers, and many of the people who watched the exchange on YouTube after it happened in October seemed to agree.

Scroll down far enough, though, and you see a different kind of response.

“What a (preplanned) snarky, mean-spirited response she made,” wrote one commenter.

Scorn,” wrote another, “mockery, contempt, self-congratulation . . . but hey, worked for Hillary, amIright?

The list of double standards women face on their path to public office is plenty long: They should be pretty, but not distractingly so. Assertive, but never aggressive. Maternal, yet devoted exclusively to their careers. And every word that passes their lips should be spoken in a tone, volume and cadence that is pleasing to the ever-alert ears of their audience.

But there’s another quality on which women can be harshly judged that’s almost always left out of the conversation: their humor.

“We often say that when women run for office they face a likability tightrope. They have to be so nuanced — and humor is a really good example of that,” says Amanda Hunter, director of research at the Barbara Lee Family Foundation. “In our likability advice we say that [female] candidates should use humor, but not too much humor.”

CNN

Mountains of research have established the advantages of a sharp sense of humor. People perceived as funny are also perceived as being confident and competent and are more likely to be elected into positions of leadership.

But there’s emerging evidence — which jibes with the sneaking suspicions of many women who’ve tried to laugh their way to the top — that’s it’s not so clear-cut. Not for them.

“Every time they display humor,” says Alyssa Mastromonaco, former deputy chief of staff in the Obama White House, of female politicians, “they’re called inauthentic or they’re trying too hard.”

It’s not limited to politics. Men are rewarded for using humor in work presentations, but women can be punished for their jokes, according to a study published last year in the Journal of Applied Psychology. Researchers asked a man and woman to each give two versions of a speech to employees. When the man included humor, he was rated higher in terms of status, performance evaluation and leadership capability. When the woman included the exact same jokes in her speech, she was rated lower on all three fronts.

Jon Evans, a doctoral candidate at the University of Arizona who led the research, theorizes that the bias is rooted in outdated standards of femininity and the idea that women can’t be as serious about their work as men because they have families to care for and that telling jokes somehow undercuts their perceived dedication to their professional mission.

At Maggie’s List, a political action committee that works to increase the number of conservative women elected to federal office, humor is seen as so risky for women that the group advises female candidates to tell jokes that would be appropriate only for a grade-school audience — or forgo trying to be funny altogether.

“Women’s humor, if taken out of context, is usually unforgiven and held against them,” says Jennifer Carroll, Maggie’s List’s spokeswoman and the former lieutenant governor of Florida. “As if to say, ‘Women should know better’ ” — that they should avoid cracking wise out of some puritan sense of what is good and proper.

But choosing to not use humor — especially if a candidate is inclined to be funny — risks endangering a whole other dimension of a candidate’s likability. People judge prospective leaders on two main characteristics, says John Neffinger, a media coach: strength and warmth. These need to be calibrated just so. Too much strength and they’re a jerk. Too much warmth and they’re weak.

Humor is one of the rare forms of communication that strike both chords, he says.

“If you tell a joke and get better than crickets — a real laugh — first of all, you just took control of the emotional state of the room. You made that happen, so that’s a check for strength,” says Neffinger. “And for warmth, what you’re doing is getting everybody on the same emotional page.”

It is possible for women to pull this off, he says. Neffinger points to former Texas governor Ann Richards — who once quipped that George H.W. Bush was born with a silver foot in his mouth — as an example of a woman who wielded humor to great effect. The fact that she was older and white-haired may have made her barbs more palatable, he speculates, and she did it with “the big ol’ Texas grin to take the edge off it.”

Here’s the catch, though: When women do use humor, says Neffinger, they should also be aware that it may be received differently than if she were a man. “The most common danger,” he says, “is a female candidate using self-deprecating humor to project warmth and totally undercutting her strength.”

So, yeah. Just balance all that perfectly and you should be fine.

Unless, of course, your constituents just don’t like your jokes and don’t know why, in which case, well . . . good luck out there!

Understanding the bias against women using humor is tricky because the prejudice is so subtle, even unconscious. Few people would ever say that they don’t like women with a sense of humor. But social conditioning around humor may run deeper than most people realize. Being funny is a type of peacocking, a way to display intelligence, and research has shown that both men and women are more likely to laugh if a man is talking to them.

Dianne Eldridge is an energy executive who manages a $250 million portfolio of factories. She’s spent 20 years rising through the ranks of an oil and gas company and, when it comes to humor, has learned to self-censor.

In one-on-one conversations and casual settings, Eldridge turns it on. “I use it to make people like me personally and say, ‘Okay, she’s not uptight,’” Eldridge explains. Once, at a steakhouse, a male colleague began making cracks about her ethnicity and asked how her dry-cleaning business was doing. “I still had a smile on my face, and I said, ‘Those are Koreans. I’m Chinese. If you’re trying to be funny, you should at least get your Asian insult right,’ ” she recalls. It defused the tension and earned her the respect of everyone at the table.

But when Eldridge finds herself speaking in front of larger groups or presenting to senior executives, she shuts off her humor entirely. It was her female mentors who advised her to do so.

“It kills me that I have to switch it off,” she says. But she can’t risk undercutting her message, even if her male counterparts are working with more slack. “Guys can go there and do a horrible joke and people let him get away with it because they trust him enough to switch and be serious,” Eldridge says. “If I do it, there’s no way.”

Rep. Katie Porter (D-Calif.), who says she has found humor useful for developing relationships with colleagues, worries that women seeking office “often get excessively coached.”

In 2018, Gretchen Whitmer, the governor of Michigan, cut a campaign video where she read mean tweets about herself and offered some snappy retorts. (“I hope you didn’t spend all night thinking that one up, Gary,” she told someone who tweeted that she should get back in the kitchen.) The governor thought that kind of breezy humor was a good look for her. But when it came time to hit the debate stage, a (male) consultant told her to draw a smiley face on her notecard so she’d remember to smile.

“That’s so saccharine and it irritated me,” Whitmer says.

She drew a shark instead. That made her laugh.

Two of the women still in the 2020 presidential race have routinely deployed humor throughout their campaigns. Amy Klobuchar almost always lands a laugh when she talks about how much money she’s raised from ex-boyfriends. And Warren has demonstrated the ability to deliver a one-liner. At a debate last month, when a moderator mentioned she’d be the oldest person ever inaugurated, she clapped back, “I’d also be the youngest woman ever inaugurated.”

Hillary Clinton has said she regrets not injecting more laughs into her 2016 campaign. “I really believed that my job, especially as a woman and as the first woman to go as far as I did, that I had to help people feel good about a woman in the Oval Office, a woman commander in chief” she said on “The View.” “I may have overcorrected a little bit.”

Still, says Mastromonaco, the former Obama staffer, “It’s hard to envision a world where [Clinton] wouldn’t have been criticized if she’d been a real cutup on Jimmy Kimmel.”

Meanwhile, President Trump gives campaign speeches laced with laugh lines — and little regard for equanimity or truthfulness.

“When you think about it,” says Mastromonaco, “his events are nothing but a stand-up routine.” (Though not a very funny one, she adds.)

The good news, says Amanda Hunter of the Barbara Lee Family Foundation, is that more women are running for office, and they’re running as their full, authentic selves. That often means using humor, whether their audiences like it or not.

Jon Evans, the University of Arizona researcher, will be glad to hear that. His report didn’t conclude that women should stop cracking jokes. It concluded that audiences should recognize their tendency to punish women for it. Because if women don’t feel free to use humor to connect with audiences, he says, “it’s one less tool in their toolbox” that could help them win.

And for everyone who wants a full sense of the people who would lead them, it’s one more loss.