When shortcodes are evaluated, the header of the site has already been assembled. So if the shortcode wants to enqueue a script it must do so in the footer (by setting the last parameter to wp_enqueue_script to true.
At this point you’re still not too late to prevent the file from actually being included in the footer. Normally, in functions.php you would enqueue or (de)register scripts with the after_setup_theme hook. However, if you look at the order in which actions are executed you would be trying to deregister a script long before it is enqueued.
So, you would have to find a hook that fires after the shortcode has enqueued the script. The logical choice would be wp_footer, like this:
add_action ('wp_footer','wpse240803_deregister_dwqa');
function wpse240803_deregister_dwqa() {
wp_deregister_script ('dwqa-submit-question');
}
Related Posts:
- How to include code only on specific pages?
- force enqueue script to be first in order of prominence
- When can you get current page ID and initialize hooks right after?
- enqueue script only if it is not already enqueue
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Pass $this to function nested in another public function of the same class
- Dequeue / Deregister script and replace it with a new plugin
- Add extra parameter in tag using script_loader_tag
- How to avoid redefining requirejs in plugin when another plugin also uses requirejs
- Problem in loading javascript in footer
- React JSX in WordPress Plugin Development
- Is there an earlier hook than login_head or login_enqueue_scripts?
- Can someone please tell me what is wrong with my plugin?
- Enqueue WordPress plugin scripts below all other JS
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Best place for short bio,image and button [closed]
- accessing wp.media api from a tinymce plugin
- How can I remove the WordPress-Version (?ver=5.x) from my plugin
- Create shortcode to echo javascript
- Redirect to another page using contact form 7? [closed]
- Is there a loading priority for login_enqueue_scripts?
- Why am I unable to load scripts in head in plugin?
- Remove / overwrite some functions in buddypress.js
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Flipping Book PHP Code? Any experience?
- Add type to enqueued script inside plugin
- Executing Javascript in Plugin
- Load CSS files in header of Bones theme?
- How to enqueue some javascript source once per page
- WordPress load same script two times
- Why does my custom plugin only function correctly once per page?
- JS working when used normally but not in wordpress
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- Why can I not deregister my style and script on custom post type?
- WordPress shortcode plugin not working
- Beginner question: Accessing js script in plugin
- WordPress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted
- plugin shortcode output
- Where are theme codes located for WordPress?
- Why do plugins often ask to add in to templates?
- plugin shortcode not working on ajax request call
- wordpress add_action() issue in ajax call
- Localizing methods for jQuery append prepend wrap parent
- Turning on output buffering in a wordpress plugin
- How to use template_include hook with form submission?
- IF condition based on wp_remote_get output
- shortcode not return any thing in Gutnburg
- Shortcode not working – quotes seems strange
- wp_trash_post hook – problem with page updating if using wp_die
- is it possible to hook every page style?
- Add the_post_thumbnail_url to a shortcode in function.php
- Enqueue script: link not working in page source
- Add action to custom Function
- Form Plugin for Api Requests which is used via Shortcode
- Echo out element to another page.
- how to request a script more than once in wordpress
- How to turn off automatic operation for Nivo Slider?
- Adding a Tag Parameter / Filter to My Shortcode
- Wp-minify doesn’t seem to minify my JS code
- Plugin Hook When New Author Added
- Edit all $wp_scripts at once to $in_footer = false
- Ajax call not working in wordpress through a plugin
- Fail on admin_enqueue_scripts when I try it to upload a CSS file to my WordPress Plugin
- Cannot run script properly with my custom plugin
- Alternative Hook to the_content for Changing Background Color
- Unpublished Pages Failing To Appear On Custom Path
- Make the product page as homepage WooCommerce
- Enqueue plugin for specific pages
- Hooking into the HTML header container
- Hide WordPress Site URL from Source Code
- Add external javascript to post template
- Get Current Post ID in WP Loop For GiveWP
- Plugin function in child theme
- AJAX update fails for public/non-admin users
- How do I keep children of certain parent menus expanded by default on a sidebar?
- Conditional Fields depending on checkboxes
- Identify if the_post hook is being called from the admin post list
- Adding javascript to header of MetroMagazine theme
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Passing a parameter to filter and action functions
- WordPress hook source
- Media Playlist Plugin
- Adding an onchange event to a custom dropdown menu in WordPress
- Possible jquery / library conflict in plugin usage
- Transition Post status not working
- Space in WordPress Attribute Causing Problems
- Shortcode registered from a plugin not recognized
- Strange get_the_* behavior with php 5.4
- Why won’t the Comprehensive Google Map Plugin load?
- OOP Plugin: Where should I place the action hooks in the class?
- Embedding BitBucket Code in Posting
- Do shortcodes affect page indexing by search engines?
- making a simple plugin
- How to show in front End images using Visual Composer attach_images?
- Javascript as Jquery Function Call?
- Shortcode to do math with url variables
- How to get URL param for pagination in shortcode?
- How to get next day date of a specific day
- I have to select text from gutenberg editor. Purpose is to store and replace text