To draw a line you might use also the very simple algorithm that uses the very simple slope formula y=ax+b (or x=ay+b). It requires one div and then uses float computations, but divs are no longer that slow now, same for float operations, and anyway such cost has to be balanced with the high number of branches that Bresenham uses.
For C++ Bresenham will be faster, for javascript the branch cost is so high that using a plain for loop with no branch will be faster.
As for the coding, slope drawing is way simpler than Bresenham.
I made a small demo in javascript, in which i included the linear interpolation (lerp) method that @amitp mentions.
lerp, used with the proper distance, the manhattan distance, generates exactly the same pointset as slope. (thx to @amitp for his comments/fiddle) .
lerp uses 4 muls , 5 add, and 2 roundings per points, when slope uses 2 add and 1 rounding per point, but lerp win on the line of code count.
fiddle is here :
http://jsfiddle.net/gamealchemist/M9y6z/4/

Code for slope drawing :
// draws a line using y=ax+b or x=ay+b function line_slope(x1, y1, x2, y2) { // round input x1 = Math.floor(x1); x2 = Math.floor(x2); y1 = Math.floor(y1); y2 = Math.floor(y2); var pxCount = 0; if (Math.abs(x1 - x2) > Math.abs(y1 - y2)) { // first quarter if (x1 > x2) { // make it from left to right var swp = x1; x1 = x2; x2 = swp; swp = y1; y1 = y2; y2 = swp; } pxCount = x2 - x1; var slope = (y2 - y1) / (x2 - x1), y = y1; for (var x = x1; x <= x2; x++, y += slope) { context.fillRect(x, y, 1, 1); } } else { // second quarter if (y1 > y2) { // make it from top to bottom var swp = x1; x1 = x2; x2 = swp; swp = y1; y1 = y2; y2 = swp; } pxCount = y2 - y1; var slope = (x2 - x1) / (y2 - y1), x = x1; for (var y = y1; y <= y2; y++, x += slope) { context.fillRect(x, y, 1, 1); } } }
and for linear interpolation (lerp) :
// draws a line using linear interpolation function line_lerp(x1, y1, x2, y2) { x1 = Math.floor(x1); x2 = Math.floor(x2); y1 = Math.floor(y1); y2 = Math.floor(y2); var length = Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)); var tIncr = 1/length ; for (var t = 0; t <= 1; t+=tIncr) { var lx = Math.round(x1 * t + x2 * (1 - t)); var ly = Math.round(y1 * t + y2 * (1 - t)); context.fillRect(lx, ly, 1, 1); } }