Make WordPress Core

Opened 10 months ago

Closed 9 months ago

Last modified 9 months ago

#59865 closed defect (bug) (invalid)

wp_enqueue_script problem

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

Description

After upgrade to 6.4.1 version I have a problem with printing scripts tag in footer.
My code is very simple:

wp_enqueue_script('sage/home.js', asset_path('scripts/home.js'), ['jquery'], null, true);

The output is:

<script type="text/javascript" src="https://mysite.dvl.to/wp-content/themes/sage/dist/scripts/home_58192a8e.js&#039; defer=&#039;defer" id="sage/home.js-js"></script>

The result is script is not loading.

I have found temporary solution in wp-includes/class-wp-scripts.php file. I have commented line 412 which is:

$src = esc_url_raw( apply_filters( 'script_loader_src', $src, $handle ) );

Can you please fix this bug?

Change History (3)

#1 @jorbin
10 months ago

  • Keywords close added
  • Severity changed from major to normal

Hi @jareksol,

I am not able to replicate this on a default install. From the looks of the tag that is printed, something is attempting to inject the defer loading strategy. This is likely a plugin or some code in your theme and is not the supported way to adjust the loading strategy.

See: https://make.wordpress.org/core/2023/10/17/script-loading-changes-in-wordpress-6-4/ and https://make.wordpress.org/core/2023/07/14/registering-scripts-with-async-and-defer-attributes-in-wordpress-6-3/

I believe this should be closed as invalid as it is not a bug in WordPress Core.

#2 @ironprogrammer
10 months ago

#59864 was marked as a duplicate.

#3 @azaozz
9 months ago

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

Also not able to reproduce this. Also wondering what's the asset_path() function used in the example, there's no such function in WP core. Seems it may be related to the problem?

Agree with @jorbin that this is most likely caused by a plugin or theme. Closing as invalid, please feel free to reopen with more details and a way to reliably reproduce.

Last edited 9 months ago by azaozz (previous) (diff)
Note: See TracTickets for help on using tickets.