Resizing changes the number of pixels. Compression changes how those pixels are encoded. A 4000px-wide photo can remain 4000px wide after compression.
What should you consider?
If the destination only displays a small image, resize first. If dimensions are already appropriate but the file is too large, compression may be enough.
Practical workflow
Start with the destination requirement, make a copy rather than overwriting an important original, and compare the output at the size where it will actually be used. If the file is still too large, consider whether resizing, compression or a different format solves the real problem.
Related tool
Tip: The smallest file is not automatically the best file. Compatibility and visible quality matter too.