Ensure script that references global objects safe on pages where global is not enqueued