Abstract For any compact Lie group 𝐺 and closed, smooth Riemannian manifold ( X , g ) (X,g) of dimension d ≥ 2 d\geq 2 , we extend a result due to Uhlenbeck (1985) that gives existence of a flat connection on a principal 𝐺-bundle over 𝑋 supporting a connection with L p L^{p} -small curvature, when p > d / 2 p>d/2 , to the case of a connection with L d / 2 L^{d/2} -small curvature. We prove an optimal Łojasiewicz–Simon gradient inequality for abstract Morse–Bott functions on Banach manifolds, generalizing an earlier result due to the author and Maridakis (2019), principally by removing the hypothesis that the Hessian operator be Fredholm with index zero. We apply this result to prove the optimal Łojasiewicz–Simon gradient inequality for the self-dual Yang–Mills energy function near regular anti-self-dual connections over closed Riemannian four-manifolds and for the full Yang–Mills energy function over closed Riemannian manifolds of dimension d ≥ 2 d\geq 2 , when known to be Morse–Bott at a given Yang–Mills connection. We also prove the optimal Łojasiewicz–Simon gradient inequality by direct analysis near a given flat connection that is a regular point of the curvature map.