Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when jquery is loaded in the footer #2

Open
BinaryTiger opened this issue Mar 19, 2015 · 2 comments
Open

Issue when jquery is loaded in the footer #2

BinaryTiger opened this issue Mar 19, 2015 · 2 comments

Comments

@BinaryTiger
Copy link

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

@kevinweber
Copy link
Owner

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

@BinaryTiger
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants