Make WordPress Core

Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#58717 closed defect (bug) (worksforme)

async

Reported by: camaran's profile camaran Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.3
Component: Script Loader Keywords: close
Focuses: Cc:

Description

i made

wp_enqueue_script( 'adsense', 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js', array(), null, array('async', false)

but in the html i not see async attribute (i use wp 6.3 beta 3)

Change History (4)

#1 @roytanck
5 months ago

Thanks for your ticket. I do not believe wp_enqueue_script supports this syntax. The fifth attribute should be a simple boolean (true or false), and determines whether the script is loaded in the footer.

It is possible however to add the async attribute using the script_loader_tag filter hook. See https://wordpress.stackexchange.com/a/198372 for an example.

#2 @camaran
5 months ago

hi, new syntax is available with wp6.3 you can see in the https://core.trac.wordpress.org/browser/trunk/src/wp-includes/functions.wp-scripts.php#L170

but in beta 3 not work

Last edited 5 months ago by camaran (previous) (diff)

#3 @TobiasBg
5 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

According to the documentation that you linked to, the newly modified parameter would have to be given as

array( 'strategy' => 'async', 'in_footer' => false )

(for example), and not as

array( 'async, false )

as in your example.

I'm therefore closing this ticket as worksforme.

#4 @camaran
5 months ago

  • Keywords close added; needs-patch removed
Note: See TracTickets for help on using tickets.