Fixes #5766 - JS code errors during elgg object construction