Highlight.js
JavaScript syntax highlighter with language auto-detection
... with zero fiddling. It is possible to use other HTML elements (or combos), but you may need to pay special attention to preserving linebreaks. You can run highlighting inside a web worker to avoid freezing the browser window while dealing with very big chunks of code.