Mucous plug

Is losing your mucous plug a gradual thing or does it happen all at once? When is the earliest it can be lost?