There's a nice compact function for creating rfc4122-compliant random UUIDs posted on my blog at:
http://www.broofa.com/2008/09/javascript-uuid-function/
Math.uuid.js is small (~400bytes), and has no dependencies on other libs, so can drop into just about any JS project. It can be used to produce either RFC4122-compliant v4 (random) uuids, or more compact, non-standard IDs of arbitrary length and base. For example:
>>> Math.uuid() // RFC4122 v4 UUID
"4FAC90E7-8CF1-4180-B47B-09C3A246CB67"
>>> Math.uuid(17) // 17 digits, base 62 (0-9,a-Z,A-Z)
"GaohlDbGYvOKd11p2"
>>> Math.uuid(5, 10) // 5 digits, base 10
"84274"
>>> Math.uuid(8, 16) // 8 digits, base 16
"19D954C3"
P.S. That blog post also links to a test page that shows the number of possible UUIDs there are for a variety of arguments, and that includes a performance test for those that care about that sort of thing.