Take it on a case by case basis.
If the small parts form a sub-assembly which is largely the same colour, then it's easier build the sub-assembly first and then prime/paint as a unit. Likewise, if it's a small part like a lifting hook which is to be glued to a tank hull, then it's preferable to attach it to the hull first and paint as a unit.
However, in some cases, access after assembly can be an issue and you may have no option but to paint certain parts before assembly.
One can prime or paint small parts while still on the sprue, but if the part requires any cleanup (eg. flash, ejector pin marks, sprue nubs, mould seams) it's going to need to be repainted/re-primed.
Painting or priming parts before assembly can also have an impact on the overall integrity of your model, as model glues don't adhere well to paint. You have to remove paint from areas where model cement is to be applied.