The electrification of wheel loaders is considered a leading trend due to its advantage of zero‑carbon emissions. However, the inevitable phenomenon of battery degradation has led to increased battery usage and maintenance costs. This study first extends the battery lifetime by optimizing the speed trajectory based on the typical loading cycle of the wheel loader. The optimal control problem is formulated by systematically modeling the wheel loader's powertrain and using a precise semi-empirical battery aging model. To reduce computational costs, the modified optimal control problem includes a weighted penalty on travel time. Unlike the conventional dynamic programming method that takes substantial computation time, a combined algorithm of dynamic programming and Brent's method (DP-BM) is first introduced to provide a numerical solution to the optimization problem with a reduced computational burden. Simulation results demonstrate that the optimized trajectory can decrease the average power consumption of the battery and reduce the number of full equivalent cycles, resulting in a 4.48% improvement in the average battery lifetime compared to the typical trajectory. Modeling errors are analyzed to make sure the results are reliable. Furthermore, the proposed approach significantly reduces computation time compared to the conventional dynamic programming method, with an average reduction of 95%. The total cost for each year is finally summarized, and the results indicate that the optimized trajectory offers a distinct advantage in terms of cost-effectiveness.