Ensure script that references global objects safe on pages where global is not enqueued
Merge pull request #5602 from getdave/master

Ensure script is safe when global var not available/enqueued