There are many different ways this can be done. I have custom visuals and lighting, but it's all triggered live. I try give a bunch of the music I might play to my VJ and LD ahead of time so they can get to know it, but that's it. If they don't know it, they just riff stuff.
the technology is called timecoding. you hit play on a song on the CDJ, the software recognises it triggers the corresponding visual. this obviously takes a lot of programming in advance but pre-recording has nothing to do with it. let's stick to talking to things we know about