Light scattering is the main limitation for optical imaging. However, light can be focused through or inside turbid media by spatially shaping the incident wavefront. Wavefront shaping is ultimately limited by the available photon budget. We developed a new 'dual reference' wavefront shaping algorithm that optimally uses the available light. Our method allows for multi-target wavefront shaping, making it suitable for transmission matrix measurements or transmitting images. We experimentally confirmed the improvement of the focus intensity compared to existing methods.