Opened 3 years ago
Last modified 3 years ago
#55030 new defect (bug)
wp_enqueue_script( 'jquery-ui-autocomplete' ) - is enqueueing a bunch of extra scripts I don't need
Reported by: | wpfed | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Script Loader | Keywords: | |
Focuses: | javascript | Cc: |
Description
When I enqueue default scripts located in WP, specifically
<?php wp_enqueue_script( 'jquery-ui-autocomplete' )
All of these extra scripts are also loaded on the front-end:
wp-includes/js/dist/a11y.min.js
wp-includes/js/dist/i18n.min.js
wp-includes/js/dist/hooks.min.js
wp-includes/js/dist/dom-ready.min.js
wp-includes/js/dist/vendor/wp-polyfill.min.js
wp-includes/js/dist/vendor/regenerator-runtime.min.js
I was using this reference:
https://developer.wordpress.org/reference/functions/wp_enqueue_script/#default-scripts-and-js-libraries-included-and-registered-by-wordpress
Is this normal behavior?
Change History (3)
Note: See
TracTickets for help on using
tickets.
I discovered that two of the extra scripts are coming from contact form 7, it adds dependency for wp-polyfill which has a dependency on regenerator.
wp-includes/js/dist/vendor/wp-polyfill.min.js
wp-includes/js/dist/vendor/regenerator-runtime.min.js
Looks like the core adds extra dependencies as well:
Looks like best practice is to not use WP packages as they add many unnecessary scripts. Unfortunately plugin authors use them sometimes which is going to slow down many sites.
This can be closed.