#JavaScript ES6, 9090 81 Bytes
f=a=>{i=new Image();i.src="//placehold.it/1x1";i.onload=b=>a(true1);i.onerror=c=>a(false);} #JavaScript ES6, 22 21 bytes (Invalid)
Some browsers don't fully support, or produce the expected result when using navigator.onLine.
f=a=>navigator.onLine