The Prophet ﷺ said, "A good word is charity, and every step taken toward the prayer is charity."
حدثنا إبراهيم عن ابن المبارك عن معمر عن همام
عن النبي ﷺ قال الكلمة الطيبة صدقة وكل خطوة يخطوها إلى الصلاة صدقة
Its isnad is sahih. It was previously mentioned at 8096, and Bukhari related it 4/43 in jihad, in the chapter on the merit of one who carries his companion's belongings while traveling, and Muslim related it 2/699, number 1009, in zakat, in the chapter explaining that the term charity applies to every kind of good deed.