Difference between imessage and text message?

I know that an imessage is only when your talking to someone on their iphone. But is that somehow triggered by Wi-Fi? My friend has an iphone and sometimes it will switch back and forth between an imessage and text message. So does imessage only work in Wi-Fi?

Yes imessage is free thru Wi-Fi

IMessage works on both Wi-Fi and a cell network. So if you're outside of cell service range, but you can still connect to the internet, then iMessage will work.

IMessages are only sent via an internet connection vs a text message which is sent using the carrier network & no internet.

I wanna know is it faster ir vetter to send an imessage thru text messageung or thru thru the imessageing? Because when you send an imessage it has the delivered under it but not all the time but when you hold diwn on your message the option of sending it thru text comes up and once you have chosen that it will say sent as text message underneath.