We study optimality of function spaces that appear in Sobolev embeddings. We focus on rearrangement-invariant Banach function spaces.