The whole telescope will be shielded from Sun and Earth light by a large sunshield. It is sized about 22 x 10 meters, giving it a instantaneous Field-of-Regard that covers about 40% of the sky at any time. The sunshield will be folded around the Optical Telescope Element during launch, giving it protection, and will be unfolded during orbit insertion.
The sunshield has a 5 layer, "V" groove radiator design of lightweight reflecting material. It reduces the 300 kilowatts it receives from the Sun to a mere 23 milliwatts at the back, sufficient to sustain a 300K temperature drop from front to back. With a back sunshield temperature of ~ 90K, the primary mirror, the optical truss, and the instrument payload can radiate their heat to space and reach cryogenic temperatures of 30-50K. These low temperatures and the total blocking of direct or reflected sunlight are crucial to the scientific success of JWST. Combined with the L2 orbit, the large sunshield provides a stable, cold environment with a minimum of background radiation.
The images below are representations of the cold and warm sides of the sunshield.