Salah, who has not been at his best since returning from injury last month, was brought on in the 79th minute, just after the Hammers' second goal levelled the game
Cesc Fabregas marked his 300th Premier League appearance with his side's opener after 19 minutes, finishing well after being picked out by Pedro's cut-back.
Swansea worked tirelessly to avoid further damage and stunned the leaders shortly before halftime when Fernando Llorente rose to head Gylfi Sigurdsson's quickly-taken free kick past Thibaut Courtois.
Swansea's hopes of a valuable point in their relegation battle ebbed away when Lukasz Fabianski allowed Pedro's shot to squirm into the net and Diego Costa wrapped up the points with his 16th league goal of the season, volleying in from Eden Hazard's pass.