I found some javascripts that allow you to generate offline private key randomly, what are the important parts of the code that I guarantee that the private key will be generated
I think you basically need to reviews the code.
Do you mindset sharing it?
Javascript's randomness is not very good.
For example, Math.random() is not really random. So if your scripts uses it, I think it is not good.
https://hackernoon.com/how-does-javascripts-math-random-generate-random-numbers-ef0de6a20131
You can try some libs such as
https://github.com/bitcoinjs/bitcoinjs-lib
https://bcoin.io/
I never used them.. but you can even run a full node using bcoin