The fire that killed at least 30 people in a warehouse-turned-performance space in Oakland, Calif., on Friday was one of the deadliest in the United States in many years, a tragedy that highlighted both the importance of fire safety codes and the vital role they have played in turning mass casualty blazes into rare events.

They have become infrequent thanks to safety measures that started to emerge at the turn of the 20th century, when fires at theaters and nightclubs not infrequently killed hundreds of people.

“The adoption and implementation of fire codes, having an effective enforcement system that’s been put in place at the city, county or state level — those have been the key elements that have made the difference we have seen,” said James Pauley, president of the National Fire Protection Association. “When a deadly fire happens it is usually because something isn’t followed or something goes wrong or we learn something new."

He pointed to the first standards for sprinkler installation and the construction of fire escape routes, implemented in the early 1900s, as a watershed moment for fire safety. Many of the new standards were motivated largely by deadly blazes like the Triangle fire in 1911, which claimed 146 lives in New York.