Sebastion Magwick's IMU and AHRS sensor fusion algorithms in JavaScript.
This is MadgwickAHRS.c and MahonyAHRS.c taken from X-IO Technologies Open source IMU and AHRS algorithms and hand translated to JavaScript.
Wrapped up in a THREE.js visualization of IMU motion.
Can be viewed in a browser from index.html or installed as a Chrome App or Chrome browser extension.
Real accelerometer, gyro and magnetometer data can be fed in via a serial link when used as a Chrome app or extension.