JohnP is correct in his answer about the order of events, but here's why. You're missing the important phrasing in the PHB entry.
If you are hidden—both unseen and unheard—when you make an attack, you give away your location when the attack hits or misses.
Not When you take the Attack Action or when the attack is otherwise made. The attack has to be resolved as a hit or miss first, and any attack that's resolved as a hit immediately does it's damage first before anything can react to being attacked.
So the act of MAKING the attack isn't what gives away the Goblins position. It's the act of said attack coming into proximity of the Goblin's target, and either hitting or missing said target that gives away the Goblins location. Allow me to add some lose RP embellishment and Environment to the scenario
On his turn, player readies an action to throw javelin when he sees goblin.
(Goblin vanishes in a field of trees, from there he could go/be anywhere when he shows up again and the Player want's to be ready for when it does.)
Goblin, on his turn, uses short bow to shoot PC, goblin rolls attack.
(Goblin sees an opportunity to attack and looses an arrow at the target from his hiding spot, but is still for intents and purposes hidden to the target.)
Goblin misses. (Arrow zooms past targets face and reveals the firing position of the goblin.)
- Player takes his readied reaction and throws Javelin at now revealed Goblin. (I'd be angry too if an arrow nearly hit me.)
- Goblin hits AND rolls damage. (Arrow embeds itself into the targets leg, definitely revealing the firing position of the goblin.)
- Player takes his readied reaction and throws the Javelin at now revealed Goblin (If he's still alive after taking that arrow to the knee, a great war story for sure!)
There are no Interrupt abilities in D&D 5E as there were in 4E (I think?), so to answer the question; No, there are no actions or reactions that I'm aware of without taking Feats that a player can do that will rob or come between an enemy dealing damage after making an attack, or before it can make said attack. Everything in the book is worded carefully to avoid that when it comes to stealth and other situations.