Mr Johnson came to the constituency to campaign with Ryan Stephenson, the Conservative candidate in next month's Batley and Spen by-election.
Voters are set to go to the polls to choose their new MP on July 1.
Mr Johnson described his visit to Fox’s as a “personal pilgrimage” because his long-time PA, Ann Sindall used to work there.
Asked about his favourite biscuit, he replied: “My favourite biscuit I had today was a Fox’s jam and cream I think it’s called. It was terrific."
Rob Beeston, managing director of Fox’s Biscuits, said: “We were delighted to host the Prime Minister, Boris Johnson at the home of Fox’s Biscuits and showcase the passion and the people behind our products.
"Since the first Fox’s biscuits were crafted in Batley in 1853, we continue to make high quality and fantastic tasting biscuits for everyone to enjoy and have a clear investment plan for growth both in the UK and worldwide.”