Only init custom js if needed

This prevents output like `var objForm = (typeof ValidForm !== "undefined") ? new ValidForm("validform_1718109020", "") : new ValidForm("validform_1718109020", "");`