Joints get stiff from non-use.
The best thing you can do for joints is move them.
The problem is that when joints hurt we don't want to move them.
So, to help eliminate the pain and soreness start motion without any weight bearing.
Make sure that you are drinking a cup of water for every 10 pounds of body weight each day.
Along with the water, make sure that you are getting trace minerals. A teaspoon of "Redmond Real Salt" each day for instance is excellent.
For knees sit on a bench or table that is tall enough to allow your legs to swing freely and swing them back and forth and around in circles in all directions.
For ankles, write the alphabet in the air with your toes.
A tablespoon of apple cider vinegar with a touch of lemon, and a tablespoon of honey in a cup of warm water helps get the calcium in the right places, even helping to dissolve calcium build ups (spurs, arthritis, etc.)
When you start to do exercises that are weight bearing be sure to do some of them very slowly so that the tendons and ligaments get stretched and worked in gentle ways. For instance do squats so lowly that it takes you 20 to 40 seconds to squat down, and another 20 to 40 seconds to come back up.