Firefighters were called in the early hours of this morning to a recycling plant in Ravensthorpe after reports of an explosion.
A staff member had heard the noise at Biffa Waste Services on Low Mill Lane and informed the fire services.
On arrival firefighters from Dewsbury Fire Station discovered flames in an industrial shredder which was in an 80x50 sized room.
Watch Commander from Dewsbury Chris Johnson said: “We got a call at 2.20am this morning.
“It was a good stop really otherwise the whole building could have been destroyed.
“We had to pump water from the River Calder to put out the flames and we managed to save a JCB.
“It was just one of those unfortunate accidents.”
Firefighters left the scene at 5am this morning.
It is believed plastic and paper got stuck in the machine leading to the fire and sounds of an explosion.
Nobody was injured in the incident.