-
Notifications
You must be signed in to change notification settings - Fork 33
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
Adding support for defer/async from WP 6.3 #2051
Conversation
These scripts are enqueued on the front end - marking their strategy as ‘defer’ will make them deferrable as long as every defentent script is also deferrable.
Co-authored-by: Eddie Daniels <[email protected]>
…tribe-common into feat/TECENG-48-defer-script
…alendar/tribe-common into feat/TECENG-48-defer-script
@@ -225,7 +225,7 @@ public function load_assets() { | |||
$this, | |||
[ | |||
[ 'tribe-accessibility-css', 'accessibility.css' ], | |||
[ 'tribe-query-string', 'utils/query-string.js' ], | |||
[ 'tribe-query-string', 'utils/query-string.js', null, null, [ 'in_footer' => [ 'strategy' => 'defer' ] ] ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing this to defer? Is that fixing a particular bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it was just to optimize the page load. @adamsilverstein ?
$tag = "<script src='{$dir}/underscore-before.js' defer></script>\n" | ||
. $tag | ||
. "<script src='{$dir}/underscore-after.js' defer></script>\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why defer to these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather we dont change the stored value for in_footer
but how we pass the existing values to the wp_register_script
.
@@ -705,7 +710,7 @@ public function register( $origin, $slug, $file, $deps = [], $action = null, $ar | |||
|
|||
// Clean these | |||
$asset->priority = absint( $asset->priority ); | |||
$asset->in_footer = (bool) $asset->in_footer; | |||
$asset->in_footer = is_array( $asset->in_footer ) ? $asset->in_footer : (bool) $asset->in_footer; // Since WordPress 6.3, this parameter accepts an array argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not change how in_footer
works, when we see the new version of WordPress just modify how we use the values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bordoni we have to change something here or the array
will be cast to a bool
everytime. Remove the casting altogether? Not sure whether this is here for a particular situation and if it will be safe to remove the casting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2054
Don't use in_footer
- use existing async
/defer
params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant was, dont use the in_footer
from Tribe Assets, use the already existing async
/defer
we have plus the in_footer
value to compose the array for WordPress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…tribe-common into feat/TECENG-48-defer-script
…/tribe-common into feat/TECENG-48-defer-script
Have to close this PR since we will be using https://github.com/stellarwp/assets/ to handle assets, this change will need to be ported over there. |
TECENG-48
Utilize defer API available in WordPress 6.3.
See #1991
Required by: the-events-calendar/the-events-calendar#4470