Opened 8 years ago
Closed 8 years ago
#37317 closed defect (bug) (fixed)
Change priority of `wp_resource_hints()` to print them earlier
Reported by: | ocean90 | Owned by: | ocean90 |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | General | Keywords: | has-patch commit |
Focuses: | performance | Cc: |
Description
As noted in https://wordpress.org/support/topic/ordering-of-dns-prefetch-preconnect?replies=2, the resource hints should be printed before scripts and styles are returned.
The current priority is 10 for wp_head
and for the admin we're using admin_head
which runs after admin_print_scripts
. We can lower the priority to 1 for the front end and should change the admin hook to admin_print_styles
.
Attachments (3)
Change History (13)
#4
follow-up:
↓ 5
@
8 years ago
- Keywords needs-refresh added
In 37317.2.diff customizer outputs the hints twice, above DOCTYPE declaration.
Additional thoughts
- On
wp_head
setting the priority to2
seems a surer way of ensuring it follows the enqueue action. - Using
1000
as a magic number foradmin_enqueue_scripts
doesn't thrill me, a low number onadmin_print_scripts
seems more likely to get the desired result.
#5
in reply to:
↑ 4
;
follow-up:
↓ 6
@
8 years ago
Replying to peterwilsoncc:
- Using
1000
as a magic number foradmin_enqueue_scripts
doesn't thrill me, a low number onadmin_print_scripts
seems more likely to get the desired result.
Did you mean admin_print_styles
here? Because admin_print_scripts
runs after styles are printed.
#6
in reply to:
↑ 5
@
8 years ago
Replying to ocean90:
Did you mean
admin_print_styles
here? Becauseadmin_print_scripts
runs after styles are printed.
I did, yes.
#7
@
8 years ago
37317.3.diff uses customize_controls_print_styles
and admin_print_styles
with a ! is_customize_preview()
condition to prevent adding hints twice to the customizer.
Discovered a few more things: