Before. Buying and installing need an internet connection, and an airport where you have no data yet is the worst place to discover that.
Buying early costs you nothing, because for most plans the days do not start until the eSIM first connects to a network at your destination. Installed at home on wifi, it sits idle until you land.
Each plan also states how long after purchase it must be installed. Check that if you are buying months ahead.