Javelin is always better choice than archer here is why.
Archer (dps) 6 pierce vs Javelinist (dps) 13 pierce
Archer (walkspeed) 9.9 vs Javelnist(wakspeed) 12.6
Archer (range) 72 vs Javelinist (range) 24
Archer (spread) 3 vs Javelinist (spread) 4
Spread of archer at maxed range is 2.1 ( at range of javelinist 0.72 )
Spread of javelinist at maxed range is 0.96
With both units having 50 hp scenario looks like this.
In case archer starts attacki