tommcfarlin/WordPress-Widget-Boilerplate

Load Scripts and Styles only on pages that use the widget

Closed this issue · 3 comments

Currently the widget loads the scripts and styles on every page of the site. Any to have them just load on front-end pages that display the widget?

@rpasillas Great question -- I really need to spend some time refactoring this particular repository.

In short, yes. It's possible to have them load on front-end pages on which the widget exists. I can give a really generic response or a particular solution to your problem.

So do you have a single page or a set of pages identified by, say, a category, tag, custom taxonomy, title, or something like that you're looking to target? Or are you just looking to target all front-end pages?

Let me know and I can provide a solution for you.

I was able to modify the boilerplate to have the scripts load only where I need them. But I panicked when my scripts stopped loading at all on my WP Engine website. The solution was working locally but not on my host so I figured I was doing something wrong, but it was a caching issue on WP Engine.

Ah, gotcha! If you've got it sorted, then I'll close the ticket but don't hesitate to open it again if you have more issues around it.