BoilWP / WordPress-Plugin-Boilerplate

Start developing your plugins straight away with this WordPress Plugin Boilerplate. All the basics are already covered for you.
http://www.sebastiendumont.com/plugins/boilerplates/wordpress-plugin-boilerplate/
Other
18 stars 15 forks source link

best practices for enqueue_scripts() #18

Open steveadamsfixedit opened 3 years ago

steveadamsfixedit commented 3 years ago

I've used the boilerplate to create a custom plugin to track user engagement analytics on live streamed video assets. included in the plugin within the /public directory are some fairly robust JavaScripts that mesh with a webhook from the stream provider and a AJAX call to track real time player events. It's my understanding that these scripts added to the enqueue_scripts() function in the public/class-plugin-name-public.php run on every single page in the rather vast WP site I'm intending to deploy it on. This seems inefficient and rather insecure... What's best practice as far as only getting the scripts to run on specific pages...for instance, making a custom theme template and only applying that template file to a page containing video assets?