“Good Boys” was quite a surprise for box office analysts this weekend. Riding off of strong reviews and audience word of mouth, Universal’s raunchy comedy about a group of sixth graders wading into the world of girls and hormones has earned a $21 million opening this weekend, nearly double the $11 million opening set by independent projections prior to release.

“It seems that Universal has cracked the comedy code and thus has been somewhat immune to the movie comedy curse by releasing a steady lineup of original and appealing comedies that have bucked the trend of audience indifference,” comScore’s Paul Dergarabedian told TheWrap.

It’s a win for comedy movies at a time when such success is becoming increasingly rare for the genre. But while other studios have contributed those occasional hits in the last three years — Warner Bros.’ “Game Night” and Lionsgate’s “Madea” series come to mind — the studio that has been by far the most consistent producer of hit comedies this decade has been Universal.

Also Read: 'Good Boys' Earns $21 Million Opening, Becomes 2nd Original Film to Top Box Office This Year

“Perhaps best not to call it a comeback,” Dergarabedian continued. “But ‘Good Boys’ can at least give the industry hope that if packaged the right way, a fresh and original comedy parked on a solid release date, with great reviews and solid marketing can be successful and that the big screen comedy can once again find favor with audiences.”

Universal’s first big hit comedy in the 2010s was in 2011 with “Bridesmaids,” a film that earned $168 million in North America and kickstarted Melissa McCarthy’s film career. A year later, the studio followed that up with “Ted,” a Seth MacFarlane R-rated laugher about a living teddy bear that grossed $218 million domestic and $549 million worldwide on a $50 million budget.

As it would turn out, “Ted” would be the last pure adult comedy to rank in the Top 10 domestic charts for a year. 2013-2015 would still see some hits for the genre, like Fox’s “The Heat” ($154 million), Sony’s “21 Jump Street” ($191 million) and Universal’s “Pitch Perfect 2” ($184 million). But since 2016, no comedy has grossed over $150 million in North America. Moviegoers are still going to cinemas for laughs, but they are getting those laughs from either family films or, if they’re rated R, hybrid genre films like “Deadpool.”

Also Read: 'Spider-Man: Far From Home' to Pass $1.1 Billion Global Gross, Becomes Sony's Top Box Office Hit

Meanwhile, plenty of comedies over the last few years have flopped, even with recognizable names as draw. A few of the casualties include:

– “The House,” a $40 million WB comedy that only grossed $34 million and became the worst wide opening weekend ever for Will Ferrell, who dominated the 2000s with comedies like “Anchorman” and “Talladega Nights.”

– “Rough Night,” a female-fronted comedy starring Scarlett Johansson that only grossed $47 million globally against a $20 million budget in 2017.

– “The Happytime Murders,” which grossed $27.5 million against a $40 million budget and was the lowest opening ever for Melissa McCarthy until the release of “The Kitchen” this past week.

– “Booksmart,” a comedy that avoided flopping this summer with $22 million grossed against a $6 million budget, but vastly underperformed relative to its critical acclaim and strong word of mouth from Memorial Day weekend audiences.

Also Read: 'Toy Story 4' Crosses $1 Billion, Fifth Disney Film to Hit Global Box Office Landmark in 2019

Part of the downward trend is that big boogeyman of theatre owners everywhere: streaming and home entertainment. It’s not like comedies have lost their popularity. Shows like NBC’s “The Good Place” and HBO’s “Barry” have earned strong fanbases, as have streaming shows like “BoJack Horseman” and “One Day at a Time.”

But the TV comedies, combined with the overwhelming amount of choices people now have both at home and at theaters thanks to the 52-week release slate, has been particularly hard on comedy films. Hits in that genre more than other genres have benefited from legging out as audiences discover the film after release. “Bridesmaids,” for example, opened to just $26 million in May 2011 but only dropped to $20 million in its second weekend, and its first 10 days of grosses only accounted for 35% of its total domestic run.

“There’s no doubt that with big movies hitting theaters every weekend, it’s harder to keep people’s attention,” Universal’s domestic distribution head Jim Orr said. “It’s harder for a comedy to overperform nowadays because of how much investment is now being put in an opening weekend. But we’ve held on by sticking to the basic principles: have a quality film made with great partners, find the best opening weekend for the film, and put some great marketing behind it.”

Also Read: 'The Art of Racing in the Rain' Set to Become Another Flop in Fox's Rough Box Office Year

Such was the case for “Girls Trip” and “Night School,” two Universal films that became the top grossing original comedies for 2017 and 2018, respectively. Both were produced by Will Packer Productions, a studio Universal has signed a first-look deal with. Both films received a Q3 release slot, with “Girls Trip” set in late July as an alternative to blockbusters like “Spider-Man: Homecoming,” while “Night School,” capitalizing off of Tiffany Haddish’s rising fame from “Girls Trip,” was set for a September release.

Backed by strong marketing aimed primarily for African American audiences, “Girls Trip” earned $115 million and “Night School” took $77.3 million. Orr notes that the push for diversity since #OscarsSoWhite has come with an increased interest in comedies rooted in ethnicity, which helped both these films and Warner Bros.’ adaptation of “Crazy Rich Asians” last year.

But “Good Boys” isn’t based on that, so Universal took a somewhat different approach. Like the other two films, it was set for release in Q3, two weeks after the last major summer blockbuster, “Hobbs & Shaw,” hit theaters. After that, the studio marketed the film primarily on the gag that its three main child leads — led by “Room” star Jacob Tremblay — were too young to see their own movie. A strong 80% Rotten Tomatoes score from critics completed the setup for an opening weekend that beat expectations.

Also Read: Disney Has Already Broken Its Own Annual Global Box Office Record With $7.67 Billion

“I’m really proud of the fact that the demographics for ‘Good Boys’ has been so diverse,” Orr said, pointing to Postrak polls that reported an opening audience breakdown of 47% Caucasian, 25% Latinx and 14% African American.

“That to me is a sign of the strength of our marketing team,” Orr added. “We have a very diverse slate every year from Will Packer comedies to Blumhouse horror, yet our marketing team finds a way to get these films, especially the original films, presented to moviegoers in a way that really attracts their interest.”

“Good Boys” isn’t going to become another “Ted” or “Bridesmaids” for Universal. But, for now, comedy has remained a consistent part of the studio’s box office success year in and year out, while other studios have only found more sporadic success.

And with a Judd Apatow comedy on their summer 2020 slate, Universal looks like they’re committing to the genre for the foreseeable future.