This topic is still a mystery about who came first. There are lots of stories about the origin of Shiv and Vishnu. According to Shiv Purana, Shiva comes first and then Vishnu. On the other hand, Vishnu Purana claimed that Shiva originated from the eyebrows of Lord Vishnu. So there is still confusion about their origin and cannot say who comes first.