Expanding foam is mixture of chemicals, including polyurethane, stored under high pressure. When used, the pressurized contents come out in a liquid form and begin to expand and harden.
Because this foam has the ability to grow quite a lot in size it's important not to use too much in any one space. It has quite a few uses around the home.
Expanding foam also doesn't attract insects or rodents, and doesn't harbor mold or fungus when conditions get damp. It's not hard to work with and it doesn't have an unpleasant odor the way some products can.
The traditional use of expanding polyurethane foam is the sealing of gaps around window jambs where air can leak in and cause drafts. Expanding foam can also be used to seal small water leaks around windows as well, but it shouldn't be the thing you rely on to keep water out of your home.
For plastic pipes that rattle when water moves through them, you can use the foam as an adhesive and space filler by spraying it around the pipe where it intersects the joists and supports in the floor. This will keep them from rattling together, and should keep the pipe from moving when the water flows through them.
This foam can be used to pack your breakables, even those that are oddly shaped or hard to wrap. If you spray the foam into a plastic bag and then seal it, you can press your breakables into the still wet foam to create a mold that fits your object's form and will protect it while you're moving it.
Expanding foam can also be used as a sort of adhesive. It can bond rocks together for a garden border, ensuring that they bond together and you don't have to keep putting them back in place.
It can even be used to build waterfalls and other landscaped features for your garden or yard.
To keep pests like squirrels and rats out of your attic or basement, you can use foam to block the holes providing them access. Because the holes are likely to be a bit bigger than a gap around a window, you should push chicken wire into the hole, and it will form an infrastructure for the foam to bond to.