The practice of using blue thead locking compounds had become standard practice in the bicycle industry in certain applications, such as brake mounting bolts.
For other applications, where you need the nut to remain in pace but allow movement of the part, you may want to consider NyLoc nuts (see pic). These are the acorn style nuts with a a nylon insert in the end. The nylon insert is slightly undersize in relation to the male thread, which actually cuts a thread into the insert. This tight fit prevents the nut from backing off under vibration.
The other, more drastic option is to safety wire the fasteners. This involves drilling a hole though the male and female fastener, then installing a wire or cotter pin (not a bicycle cotter) to prevent the nut backing off. Of course this is impractical on smaller fasteners. We used to do this a lot on motorcycles, particularly British and US twins, prior to the development of thread locking compounds.