optimizing script added to header