Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify preconnect and remove prefetch #914

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@ public function insert_gtm_body() {
public function change_to_preconnect_resource_hints( $hints, $relation_type ) {

if ( 'preconnect' === $relation_type ) {
// Used for analytics inserted by insert_google_analytics().
$hints[] = array(
'crossorigin' => '',
'href' => '//www.googletagmanager.com',
);
// Used by ReCaptcha.
$hints[] = array(
'crossorigin' => '',
'href' => '//www.gstatic.com',
);

// used by HubSpot forms.
$add_urls = array(
'https://js.hscollectedforms.net',
'https://js.hs-banner.com',
Expand All @@ -150,6 +138,10 @@ public function change_to_preconnect_resource_hints( $hints, $relation_type ) {
'https://landscape.cncf.io',
'https://cmp.osano.com',
'https://consent.api.osano.com',
'//www.googletagmanager.com',
'//www.gstatic.com',
'https://browser-update.org',
'https://js-agent.newrelic.com',
);
// add crossorigin, remove protocol.
foreach ( $add_urls as $url ) {
Expand All @@ -159,10 +151,9 @@ public function change_to_preconnect_resource_hints( $hints, $relation_type ) {
);
array_push( $hints, $url );
}
}
if ( 'dns-prefetch' === $relation_type ) {
} elseif ( 'dns-prefetch' === $relation_type ) {
// create array of URLs to remove from prefetch.
$url_arr = array( 'code.jquery.com', 's.w.org' );
$url_arr = array( 'code.jquery.com', 's.w.org', 'cmp.osano.com' );

foreach ( $url_arr as $url ) {
$key = array_search( $url, $hints, true );
Expand Down
Loading