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

Add a note to the Cookie Notice description in the plugin repository on wordpress.org that jQuery is a dependency #33

Open
rpkoller opened this issue Jun 3, 2018 · 1 comment

Comments

@rpkoller
Copy link

rpkoller commented Jun 3, 2018

There is one thing with the Cookie Notice plugin that took me a while to figure out. When I've installed and activated it Cookie Notice should basically work out of the box and display a cookie notice right on page load. But it has not. The odd thing was that the markup of the cookie notice was showing but the display:nonewasn't removed. Then i realized that Cookie Notice requires jQuery. And if you are like me and have deregistered jquery on the front-end

if( !is_admin() ){
   wp_deregister_script( 'jquery' );
}

then you have no show of the notice. and i've noticed several issues on the plugin support forum stating that the plugin isn't showing like in my described case. might be cuz of the same reason.

@rpkoller rpkoller changed the title Add a note to the Cookie Notice description in plugin repository on wordpress.org that jQuery is a dependency Add a note to the Cookie Notice description in the plugin repository on wordpress.org that jQuery is a dependency Jun 3, 2018
@chesio
Copy link
Contributor

chesio commented Aug 1, 2018

Hi @rpkoller ,

Normally, there is no need to remove jQuery from front-end, because WordPress core does not enqueue it by default (it only registers it for plugins/theme to declare their JS assets as jQuery dependencies). So jQuery should be enqueued only if a plugin (or theme) says it needs it. Like Cookie Notice plugin properly does here.

I know that some themes enqueue jQuery explicitly, even if it's not actually needed by another JS asset. In such case, I would recommend using wp_dequeue_script instead of wp_deregister_script as the latter effectively says there is no jQuery available as dependency (and breaks as soon as there is a plugin that needs it as it was in your case).

Cheers,
Česlav

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