[null,null,[],[],[],null,["# Collapse empty ad slots\n=======================\n\nBy default, ad slots which are not filled are left visible, which may result in\nblank space on your page. If you know ahead of time that one or more ad slots on\nyour page are unlikely to get filled, you can instruct the Google Publisher Tag\n(GPT) library to collapse them.\n| **Caution:** Incorrect use of this feature can cause additional reflow of the content of your page.\n\nThe optimal configuration of this feature will depend on how often you expect ad\nslots to be filled:\n\n1. If slots will be filled most of the time, use [`collapseDiv: 'ON_NO_FILL'`](//developers.google.com/publisher-tag/reference#googletag.config.PageSettingsConfig.collapseDiv). In this configuration, ad slots are expanded by default and collapse only if they cannot be filled.\n2. If slots will not be filled most of the time, use [`collapseDiv: 'BEFORE_FETCH'`](//developers.google.com/publisher-tag/reference#googletag.config.PageSettingsConfig.collapseDiv). In this configuration, ad slots are collapsed by default and only expand if they can be filled.\n\nBecause `googletag` API calls have no effect until GPT begins to run, to\nminimize reflow you will also need to configure the CSS on your page so that\nslots which are collapsed by default have zero dimensions.\n\nIt's also possible to configure per-slot overrides, as shown in the example\nbelow, if specific slots on your page are more or less likely to be filled.\n\nSample implementation\n---------------------\n\n[View demo](https://googleads.github.io/google-publisher-tag-samples/collapse-empty-ad-slots/js/demo.html) \n\n### JavaScript\n\nLoading...\n----------\n\nLoading...\n----------\n\n[Improve this sample](https://github.com/googleads/google-publisher-tag-samples/tree/main/dist/collapse-empty-ad-slots/js) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback%3A+collapse-empty-ad-slots/js)\n\n### TypeScript\n\nLoading...\n----------\n\nLoading...\n----------\n\n[Improve this sample](https://github.com/googleads/google-publisher-tag-samples/tree/main/dist/collapse-empty-ad-slots/ts) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback%3A+collapse-empty-ad-slots/ts)"]]