The characterization of quantum critical phenomena is pivotal for the understanding and harnessing of quantum many-body physics. However, their complexity makes the inference of such fundamental processes difficult. Thus, efficient and experimentally non-demanding methods for their diagnosis are strongly desired. Here, we introduce a general scheme, based on the combination of finite-size scaling and the linear response of a given observable to a time-dependent perturbation, to efficiently extract the energy gaps to the lowest excited states of the system, and thus infer its dynamical critical exponents. Remarkably, the scheme is able to tackle both integrable and non-integrable models, prepared away from their ground states. It thus holds the potential to embody a valuable diagnostic tool for experimentally significant problems in quantum many-body physics.