Issue when jquery is loaded in the footer
Hi,
The modal is loaded before jQuery when jQuery is placed in the footer (with roots theme framework by example). Issue is easily fixed by wrapping the content of load_footer_script() (line ~77 to line ~183 in frontend/class-frontend.php) with a pure JavaScript "ready function" (document.addEventListener('DOMContentLoaded', function(){ /* CONTENT */ }); I can issue a pull request if you want or you can implement a "cleaner" version if you prefer.
Thank you,
BT
Hi, thanks for your hint! I'm already using a "ready function" (https://github.com/kevinweber/wbounce/blob/master/frontend/class-frontend.php#L82). So I don't know what I should change to solve your issue. Feel free to send a working pull request.
Have you tried the plugin's option "Load script in footer"? You find it on the options page of the plugin.
Best regards, Kevin
Hey,
Sorry I was not clear in the first message. The problem come from the fact that the ready function need jquery and jquery is loaded after. In the footer the order is:
your modal your modal javascript (the one that use the ready function) jquery modernizr, bootstrap, etc
I assume you hook to the start of the footer (when the option is selected in the option panel) and add your code. I fixed it by replacing the jQuery ready function with a plain and pure JavaScript "ready" function. I will send you a pull request Monday when I'm at work or this weekend if I ever get time to set up a wamp stack and a fresh WordPress (just re installed windows). It's gonna be easier to see what I'm talking about.
Honestly I don't think it affects a lot of people. We used Roots starter theme to create our own and I think it messes up with your plugin when all scripts are loaded in the footer.
Beside that, nice plugin, even if I don't like sites that use popup like that haha. I'm not the one choosing what we do, so for what it does, it does it well.
Thank you,
BT