Skip to content

Commit

Permalink
Consolidate preconnect functions
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Abraham <[email protected]>
  • Loading branch information
cjyabraham committed Dec 20, 2024
1 parent 1169ca1 commit 114b6da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ private function define_public_hooks() {
$this->loader->add_filter( 'the_seo_framework_title_from_generation', $plugin_public, 'add_year_to_archive_titles' );
$this->loader->add_filter( 'excerpt_more', $plugin_public, 'new_excerpt_more' );
$this->loader->add_filter( 'excerpt_length', $plugin_public, 'custom_excerpt_length', 999 );
$this->loader->add_filter( 'wp_resource_hints', $plugin_public, 'change_to_preconnect_resource_hints', 10, 2 );
$this->loader->add_filter( 'script_loader_tag', $plugin_public, 'defer_parsing_of_js', 10, 3 );
$this->loader->add_filter( 'the_seo_framework_image_generation_params', $plugin_public, 'my_tsf_custom_image_generation_args', 10, 3 );
$this->loader->add_filter( 'tiny_mce_plugins', $plugin_public, 'disable_emojicons_tinymce' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,6 @@ public function defer_parsing_of_js( $url ) {
return str_replace( ' src', ' defer src', $url );
}

/**
* Fix preconnect and preload to better optimize loading. Preconnect is priority, must have crossorigin; Prefetch just opens connection.
*
* @param string $hints returns hints.
* @param string $relation_type returns priority.
*/
public function change_to_preconnect_resource_hints( $hints, $relation_type ) {

if ( 'preconnect' === $relation_type ) {
$hints[] = array(
'href' => '//www.googletagmanager.com',
'crossorigin' => '',
);
$hints[] = array(
'href' => '//bam-cell.nr-data.net',
'crossorigin' => '',
);
}
return $hints;
}

/**
* Changes the ellipses after the excerpt.
*
Expand Down Expand Up @@ -356,6 +335,8 @@ public function dns_prefetch_to_preconnect( $urls, $relation_type ) {
'https://js.hsforms.net',
'https://js.hs-scripts.com',
'https://cmp.osano.com',
'//www.googletagmanager.com',
'https://js-agent.newrelic.com',
);

// add them to the urls list.
Expand Down

0 comments on commit 114b6da

Please sign in to comment.