Attempting to resolve a bug that cropped up after moving script tags to end of body