* Called to instruct the element to preconnect to hosts it uses during * layout. * @param {boolean} onLayout Whether this was called after a layout. * TODO(#31915): remove once R1 migration is complete.
(onLayout)
| 905 | * TODO(#31915): remove once R1 migration is complete. |
| 906 | */ |
| 907 | preconnect(onLayout) { |
| 908 | devAssert(this.isUpgraded()); |
| 909 | if (onLayout) { |
| 910 | this.impl_.preconnectCallback(onLayout); |
| 911 | } else { |
| 912 | // If we do early preconnects we delay them a bit. This is kind of |
| 913 | // an unfortunate trade off, but it seems faster, because the DOM |
| 914 | // operations themselves are not free and might delay |
| 915 | startupChunk(this.getAmpDoc(), () => { |
| 916 | if (!this.ownerDocument || !this.ownerDocument.defaultView) { |
| 917 | return; |
| 918 | } |
| 919 | this.impl_.preconnectCallback(onLayout); |
| 920 | }); |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | /** |
| 925 | * See `BaseElement.R1()`. |
no test coverage detected