I have also had some good luck with SVG for online graphics. They
work pretty well in recent browser versions of at least Firefox,
Chrome, IE (9 & 10), and Safari.
Of course you can also up the resolution as Ista showed you. I will
point out that depending on the elements of the image, vector graphics
can be huge or small. For example a barplot with three bars may be
quite small in vector graphics. A scatter plot with 15 million points
will be a nightmare and you would almost certainly want to
pre-rasterize that (not serve the data and force poor users' browsers
to do that).
This strays from ggplot2, but if you have many of these on a single
webpage and typical users are only interested in a handful, you might
serving thumbnails on the initial page that when clicked take you to
the full image. This can speed things up for your users and decrease
the bandwidth you are using. Just as a quick example of how easy
these are to automatically make, I have three test images from R in
various resolutions and dimensions, which I want to scale all to have
about a total of 10000 pixels
Joshua@Nessa ~/pictemp
$ ls
test1.png test2.png test3.png
Joshua@Nessa ~/pictemp
$ identify *.png
test1.png PNG 672x672 672x672+0+0 8-bit PseudoClass 46c 14.5KB 0.000u 0:00.000
test2.png[1] PNG 1220x895 1220x895+0+0 8-bit PseudoClass 46c 20.4KB
0.000u 0:00.000
test3.png[2] PNG 1220x502 1220x502+0+0 8-bit PseudoClass 46c 16.9KB
0.000u 0:00.000
Joshua@Nessa ~/pictemp
$ convert *.png -resize 10000@ thumbnail.png
Joshua@Nessa ~/pictemp
$ ls
test1.png test2.png test3.png thumbnail-0.png thumbnail-1.png thumbnail-2.png
Joshua@Nessa ~/pictemp
$ identify *.png
test1.png PNG 672x672 672x672+0+0 8-bit PseudoClass 46c 14.5KB 0.000u 0:00.000
test2.png[1] PNG 1220x895 1220x895+0+0 8-bit PseudoClass 46c 20.4KB
0.000u 0:00.000
test3.png[2] PNG 1220x502 1220x502+0+0 8-bit PseudoClass 46c 16.9KB
0.000u 0:00.000
thumbnail-0.png[3] PNG 100x100 100x100+0+0 8-bit DirectClass 10.5KB
0.000u 0:00.000
thumbnail-1.png[4] PNG 117x86 117x86+0+0 8-bit DirectClass 8.19KB
0.000u 0:00.000
thumbnail-2.png[5] PNG 156x64 156x64+0+0 8-bit DirectClass 9.38KB
0.000u 0:00.000
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/