#37694 closed defect (bug) (invalid)
Can't disable dns-prefetch to s.w.org
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.6 |
Component: | Script Loader | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
According to the ticket #34292, dns-prefetch to s.w.org can be disabled with the following code (modified with the actual function):
function trac34292_example_resource_hints( $hints, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { return array_diff( $hints, wp_dependencies_unique_hosts() ); } return $hints; } add_filter( 'wp_resource_hints', 'trac34292_example_resource_hints', 10, 2 );
However this doesn't work. I still see the dns-prefetch in HTML.
Change History (3)
#1
@
9 years ago
- Component changed from General to Script Loader
- Description modified (diff)
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.
Hey there,
This code snippet I shared on #34292 was for removing resource hints for scripts and styles, not the s.w.org domain. That's why it doesn't work.
return array_diff( $hints, wp_dependencies_unique_hosts() );
means "keep all but scripts & styles".Instead, you'd want
array_diff( wp_dependencies_unique_hosts(), $hints )
, i.e. "keep scripts & styles but nothing else.