0

I'm new to WP dev and I want to add my own CSS/JS to an existing plugin via an extension that runs after the plugin has loaded (e.g. do_action('plugins_loaded')). This plugin did not have a payment system integrated, so I'd like to integrate the Braintree API. The payment form requires me to use their JS to submit payment info to their servers. However, should I simply use wp_enqueue_script in the __construct part of my extension plugin's main class to add the Braintree JS code and leave it like that? Or should I enqueue specifically in a certain place and then dequeue it?

TL;DR - When using JS from a payment processing company, should they be enqueued then dequeued?

0

dequeue means it should be removed from the queue. All the scripts in the queue get loaded at page load. Once the page is loaded, you cannot use dequeue to remove the script.

Best is to only load the scripts you really need. You might load it conditionally in the constructor based on which page is loaded. In your case, the page(s) with the paymentform on it. Hope this helps.

| improve this answer | |

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.