i have installed discourse on localhost on windows but the problem is very very slow loading
That’s the nature of a development installation.
but it is very slow like it takes 20 seconds to load
Yes. Really. That is correct. It takes less time after the initial load, but the first load takes a very long time to load all of the assets.
If you want to use discourse and not do development then follow the cloud install instructions.