WordPress.org

Make WordPress Core

Opened 17 months ago

Last modified 3 months ago

#22739 new defect (bug)

wp_register_script/wp_enqueue_script problem

Reported by: tigusigalpa Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 3.4.2
Component: Script Loader Keywords: reporter-feedback
Focuses: Cc:

Description

First of all: sorry for my bad English.
Hi, i've seen may be a bug while programming a plugin (Len Slider).
I have some handle-scripts like jquery, jquery-ui to enqueue, its ok. Also I have my known js-files to enqueue, ok too. BUT! When I want to enqueue dynamic js (gets from folders via glob), it enqueue too BUT BEFORE jquery, jquery-ui itc. When I enqueue script with custom handle and in foreach loop, BUT with deps parameter as array of jquery, jquery-ui etc. And this dynamic js-file loads BEFORE jquery or jquery-ui! Now I solve the problem by load known handles jquery, jquery-ui in header and my own in footer, but i think we need to look for core to solve it.

You can see it on Len Slider in len-slider/lib/lenslider.class.php:313 - lenslider_make_skins_files_wp_head method

Also I think about parameter like priority for wp_register_script/wp_enqueue_script(style) functions to load it by this range.

Change History (5)

comment:2 follow-up: SergeyBiryukov17 months ago

  • Keywords reporter-feedback added; needs-patch dev-feedback removed

Could not reproduce. My steps:

  1. Install Len Slider 1.2.
  2. Create a slider with nemo_target skin.
  3. Insert the slider into a post.
  4. View the post.
  5. nemo-target-skin.js is properly enqueued after jQuery and jQuery UI.

Can you provide an example code to reproduce the issue directly?

Version 0, edited 17 months ago by SergeyBiryukov (next)

comment:3 in reply to: ↑ 2 ; follow-up: tigusigalpa17 months ago

Replying to SergeyBiryukov:

Could not reproduce. My steps:

  1. Install Len Slider 1.2.
  2. Create a slider with nemo_target skin.
  3. Insert the slider into a post.
  4. View the post.
  5. nemo-target-skin.js is properly enqueued after jQuery and jQuery UI.

Can you provide an example code to reproduce the issue directly on a clean install?

Yes, because I divided scripts in foreach loop and known-handles (jquery, jquery-ui): known in header, dynamic in footer, if you can to do on Len Slider: len-slider/lib/lenslider.class.php:331 - remove last 2 parameters , false, true and scripts from loop will be before jquery-ui. I dont want to divide like i do, but enqueue in foreach loop makes scripts before jquery-ui.

comment:4 in reply to: ↑ 3 SergeyBiryukov15 months ago

Replying to tigusigalpa:

if you can to do on Len Slider: len-slider/lib/lenslider.class.php:331 - remove last 2 parameters , false, true and scripts from loop will be before jquery-ui.

Just tried that too. Still, nemo-target-skin.js is properly enqueued after jQuery and jQuery UI.

3.4.2:

<script type='text/javascript' src='http://trunk.wordpress/wp-includes/js/jquery/jquery.js?ver=1.7.2'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-content/plugins/len-slider/js/default-skin-custom.js?ver=3.4.2'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-content/plugins/len-slider/skins/nemo_target/output/js/nemo-target-skin.js?ver=3.4.2'></script>

3.6-alpha-23288:

<script type='text/javascript' src='http://trunk.wordpress/wp-includes/js/jquery/jquery.js?ver=1.9.0'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-includes/js/jquery/jquery-migrate.js?ver=1.0.0'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.9.2'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.9.2'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js?ver=1.9.2'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-content/plugins/len-slider/js/default-skin-custom.js?ver=3.6-alpha-23288'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-content/plugins/len-slider/js/jquery-ui-tabs-rotate.js?ver=3.6-alpha-23288'></script>
<script type='text/javascript' src='http://trunk.wordpress/wp-content/plugins/len-slider/skins/nemo_target/output/js/nemo-target-skin.js?ver=3.6-alpha-23288'></script>

comment:5 nacin3 months ago

  • Component changed from General to Script Loader
Note: See TracTickets for help on using tickets.