LateButEarly/simple-facebook-page-widget

Problematic call to wp_enqueue_script

Closed this issue · 3 comments

Hello,

I noticed that wp_enqueue_script invocation as done by plugin is a bit problematic:

wp_enqueue_script( 'sfpp-fb-root', SIMPLE_FACEBOOK_PAGE_DIR . 'js/simple-facebook-page-root.js', array( 'jquery' ), true );
  1. It declares dependency on jQuery, despite that JS code in enqueued file does not seem to utilize jQuery in any way.
  2. The $ver (4th) parameter of wp_enqueue_script is set to true - it doesn't make much sense to me :) It basically sets version number to 1, I guess this was not intended and the true value was perhaps meant for the $in_footer (5-th) parameter.

Why this is an issue to me: the invocation as it is now makes it impossible to requeue jQuery in site footer, because it enqueues script declared as jQuery-dependent in site head.

Greetings,
Česlav

Great catch!

Those are both very valid points. I will make a modification to the plugin today & push an update.

Should be good to go! Took a bit longer because I had a user reported issue that was also addressed.

I'm super happy you found that because I wrote that code what seems like ages ago.

The plugin needs to be refactored, but I've always believed in "If it ain't broke, don't fix it." :)

Thanks for the fix! Works like a charm :)