Detecting Retina Display with Javascript and CSS

I recently worked on a project that requires detection of retina display or retina support. We needed the detection in a JavaScript file and a CSS style sheet. After googling for a while, we ended up using the following codes.

This post is actually a note to myself should incase a need for this arises again in future.

For CSS, use any of the below.

La Fin!

Don't miss my updates.
Subscribe to Receive Programming, Web development, Git and WordPress Tutorials & all things tech.