is_smart_lcp_enabled() || ! $this->is_lcp_preload_enabled() || empty( $this->lcp_candidate['preload_url'] ) ) {
return;
}
$url = esc_url( (string) $this->lcp_candidate['preload_url'] );
if ( '' === $url ) {
return;
}
$imagesrcset = '';
$imagesizes = '';
if ( ! empty( $this->lcp_candidate['is_img'] ) ) {
$imagesrcset = ! empty( $this->lcp_candidate['srcset'] ) ? (string) $this->lcp_candidate['srcset'] : '';
$imagesizes = ! empty( $this->lcp_candidate['sizes'] ) ? (string) $this->lcp_candidate['sizes'] : '';
}
echo '' . "\n";
$this->lcp_candidate['preload_applied'] = true;
$this->persist_lcp_report();
$this->debug_lcp_log( 'preload_applied', array( 'preload_url' => $this->lcp_candidate['preload_url'] ) );
}
public function print_smart_lcp_debug_console_log() {
if ( ! $this->is_lcp_debug_enabled() || empty( $this->lcp_candidate ) ) {
return;
}
$payload = wp_json_encode( $this->get_lcp_debug_payload() );
if ( ! is_string( $payload ) || '' === $payload ) {
return;
}
/*
* lcp_candidate is only filled in by apply_smart_lcp_optimization_to_html()
* while the page output is being rendered, so this cannot be enqueued on
* wp_enqueue_scripts without always reporting an empty payload. It stays on
* wp_footer and is emitted through the WordPress inline-script API rather
* than a hand-built