Ever notice how your latte or foamy beer never seems to spill and slosh all over the place, even if you’re jostling your cup about in a café or bar?

Researchers at Princeton University did, and decided to find out if there was a scientific explanation. Turns out, there is, and the discovery could have applications for the safe transportation of hazardous liquids.

In a study recently published in the journal “Physics of Fluids,” the team of researchers found that a few layers of bubbles, or foam, can almost halt the “sloshing motion” of a liquid, hot or cold, in a container.

Researcher Alban Sauret said he was out in a pub when he noticed how little spillage his mug was producing.

“We noticed that when we were carrying a pint of Guinness, which is a very foamy beer, the sloshing almost didn’t happen at all,” Sauret said in a news release about the study. Similarly, another researcher found that when she ordered a latte at a coffeehouse, her lid didn’t require a stopper.

Sauret and his fellow researchers decided to put their real-world observations to the test.

Placing a solution of water, glycerol and dishwashing detergent in a glass container, the researchers experimented by injecting air to create a layer of bubbles, each two millimetres in diameter.

"The dishwashing foam is very stable, which allowed us to conduct the experiments without the bubbles disappearing," said François Boulogne, one of the team researchers.

The scientists then “jolted” the solution-filled container with a rapid side-to-side motion, or rocked it back and forth.

Using a high-speed camera to capture the movement, the researchers found it only took five layers of foam to lower the wave height of the liquid bath by a factor of 10.

“We conclude that only the bubbles close to the walls have a significant impact on the dissipation of energy,” the researchers wrote.

While avoiding splash burns as you balance your morning cup of java may seem insignificant, researchers suggest their results may have practical industry uses, particularly those involving the transportation of liquefied gas in tankers or propellants in rocket engines.

Sloshing, they said, can place pressure on the walls of a tanker, which can disrupt the vehicle’s motion and cause damage.

The researchers are hoping their study may lead to more affordable and efficient methods to transport large amount of fluids.

“The potential applications are much bigger than just beer,” Sauret said.