Enqueue script in footer
-
Aloha @pavex,
We were having difficulty getting albums embedded via shortcode to work unless we manually added the script tag for
pa-embed-player.min.jsto the page content.I determined this was because the plugin enqueues the javascript in the html
<head>, which means it is loaded before the DOM is created, so it doesn’t find anydiv.pa-embed-playerelements to render.The fix is simple: use the 5th param to
wp_enqueue_scriptsto load the script in the footer, so it executes after the DOM is loaded.
https://developer.wordpress.org/reference/functions/wp_enqueue_script/In your source, change line 92 of
pavex-embed-google-photos-album.phpto:
wp_enqueue_script(self::$name, $this->player_js, array(), false, true);Thanks for the excellent plugin!
The topic ‘Enqueue script in footer’ is closed to new replies.