0

In attempting to boost the performance of my website, I've noticed that Wordpress is enqueuing a lot of the admin relevant scripts and stylesheets on the front end.

I'm wondering how I can stop this from happening...I was thinking about dequeueing all of the offending, but then my server response time would be slightly slowed.

Is there a tried and tested way of doing this?

  • The only scripts that should be enqueued from the front-end are /wp-includes/js/wp-embed.min.js and /wp-includes/js/wp-emoji-release.min.js. If other scripts are enqueued, something in your theme or plugins must be doing this. – MikeNGarrett Apr 5 at 16:41
  • Yeh, I think that's kind of what I'm asking. i.e., how to stop this behaviour. It's a custom theme, and haven't set anything up in place. I have everything that is available when logged in available when not and on the front end... – Wind Up Lord Vexxos Apr 5 at 16:43
  • @MikeNGarrett Very minimal amount of plugins installed, mainly just using ACF. Wordpress version is the latest version as well, as of today. It's not a bug is it? – Wind Up Lord Vexxos Apr 5 at 16:45
  • Just to make sure, are you looking at the front-end as a logged-in user or are you totally logged out? – MikeNGarrett Apr 5 at 16:46
  • 1
    @MikeNGarrett Hi Mike - your suggestion of changing the naming conventions of the enqueued scripts and styles worked, so there must have been something non-unique in the names of one of these that was causing a conflict. Obvious when I think about it. Wordpress 101. If you answer with this, I can accept. Many thanks if you don't have time. – Wind Up Lord Vexxos Apr 8 at 9:19
1

If your bootstrap or other enqueued scripts have a dependency or name conflict, this could enqueue all these scripts. There are a large number of common scripts in WordPress core that are enqueued under common names. I always recommend prefixing your script names with something specific.

wp_enqueue_script( 'theme-bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js', array( 'jquery' ), '4.3.1', true );
  • 2
    Yeh, I made the rookie mistake of not prepending the enqueued script names with the theme name. Will never make this mistake again. – Wind Up Lord Vexxos Apr 12 at 9:30
  • Glad you got it figured out! – MikeNGarrett Apr 12 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.