How do gas fees work on exchanges and purchases?

I read in one of your articles that Gas fees on sales and dispositions are deducted from proceeds.

Is the same true for exchanging one asset for another? How do gas fees from purchases get applied to my taxes?