NEW YORK — As a knot of journalists stood across from a mortuary witnessing a funeral for a child killed in the Uvalde school massacre, some people passing by didn’t disguise their anger.

“Y’all are the scum of the Earth,” said one woman, surveying the cameras.

When tragedy comes to town in the 21st century, the media follows, focusing the world’s eyes on a community during its most difficult hours. Columbine, Sandy Hook, Robb Elementary — the list of places synonymous with horrible mass killings keeps growing.

Journalists are called upon to explain what happened, and sometimes to ask uncomfortable questions in places where many people want to be left alone to grieve. Is it possible to do it better, to co-exist within a moment no one wants to be part of?

Tempers have flared in Uvalde, Texas.

One female journalist was told, “I hope your entire family dies in a massacre.”

Some are threatened with arrest for trespassing while on public property. A group called Guardians of the Children blocked camera views, often with the encouragement of police.

Yet there are also people like Ben Gonzalez, who approached reporters near the mortuary after hearing the woman lash out to say that she doesn’t speak for everyone.

“Thank you for documenting this tragedy,” he said. “We’ll look back at the photos you take and appreciate it.”

The shady courthouse square in Uvalde has been dotted by canopies erected by TV news crews. Journalists have been stationed at Robb Elementary School, where the shooting took place, near a makeshift memorial piled with flowers, stuffed animals and messages. At the local Starbucks, where many journalists go to work, tables are set aside for Uvalde residents.

These are the typical signs of the invasion of journalists that accompanies such events.

“I respect the wishes of people if they want me to leave,” said Guillermo Contreras, a senior writer at the San Antonio Express-News. “By the second day (after the shooting), the people were overwhelmed. The town has been overrun by reporters.”

Like most colleagues, Contreras tries to be sensitive to what Uvalde’s people are enduring. He has a 10-year-old daughter at home.

“When you are at the epicenter of a situation like that, you really do need protection,” said Michele Gay, who lost her daughter Josephine in the Newtown school shooting a decade ago. “You are really not in a state of mind to be offering your feelings in front of the camera.”

Kelly McBride, an expert on journalism ethics at the Poynter Institute for Media Studies, advises news organizations to better prepare when assigned to these stories. Most interviews on the street indicate this work hasn’t been done; people in shock and trauma, she said, shouldn’t have to make an on-the-spot decision about dealing with a reporter.

In Uvalde, questions raised about the police response to the shooting have lengthened the time the shooting has lingered in the news and increased hostility toward journalists.

CNN used a tag team to stake out Pete Arredondo, the schools police chief who directed operations, and get an ambush interview.

“You have people who are supportive of law enforcement,” Contreras said. “It’s a small town; people know each other. All of a sudden people are pointing fingers at the officers you know, so there’s a division.”