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
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- Loading external page template and enqueue script from plugin causes 403 forbidden error
- WP showing “warning: call_user_func_array()”, What to do?
- How do I only load a plugin js on it’s settings pages?
- Including javascript for a shortcode
- change plugin shortcode function [closed]
- Adding dynamic section to WordPress
- Custom data-id wp_enqueue_script
- woocommerce product attributes
- plugin_action_links_{$plugin_file} hook not in the main plugin file
- template_redirect not being called when using ajax
- Hook to generate a dynamic sitemap with “All in One SEO Pack” Plugin
- How to correctly detect accessing wp-content/uploads?
- How to generate CSS from a shortcode within a plugin
- Convert HTML Script to Shortcode [closed]
- add mediaelement.js plugins into WordPress video player control bar
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- Internationalization autocomplete JS variable
- How to remove html code in excel downloads using phpspreadsheet with wordpress plugins shortcode
- How to put JQuery/Ajax inside shortcode?
- WordPress function not being called from jQuery method
- Using a post-signup hook to get user details
- Filtering WooCommerce Orders by Category
- Add custom JavaScript that is a combination of CDN/uploaded files and easily-edited code?
- how to insert a HTML form into a javascript popup?
- Display a consistent Google Plus icon on ALL pages of my site
- Return multiple values in a shortcode attribute
- What are admin hooks
- get specific value of a array | PHP
- How to change shortcode’s default theme?
- Custom plugin – load enqueue only for this plugin
- Function added to hook “new_to_publish” not executing – custom plugin
- Meta slider plugin only works after first refresh – Object has no method ‘flex slider’
- Javascript from Easy-Fancybox place into footer
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- How do I minify a plugins CSS/JS code?
- Elementor Pro display featured image on section -> style -> image using shortcode
- Use a hook or filter, or overwrite this Gamipress function?
- Hook from plugin doesn’t fire up from external PHP script
- Stop a script on a single page
- save_post hook partly firing in update post
- Get Shortcode output to database for static post_content
- Show post object of any page in frontend
- Website always load twice on start
- Issue Saving Posts That Contain Shortcode
- Use action, filter, or hook to append HTML to WordPress plugin function
- Hook to display element as product on category page
- Speeding up WordPress on a Local Network
- Number format in thousands on highcharts in wpdatatable plugin
- Embed Javascript code to registered users only
- Find all strings between an enclosing shortcode
- How to set up php,javascript and css to allow for our finished product to be displayed within a page?
- How to load a plugin when doing an Ajax call? [duplicate]
- Is it right way to create shortcode?
- Trying to override/intercept a PhotoMosaic gallery link in WordPress using jQuery
- Creating Features List in WordPress Post
- How to make a rest style plugin?
- I am experiencing difficulty fulfilling client request
- is_user_logged_in() undefined at shutdown in plugin context
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode
- this code is fiven by chat-gtp but nothing match even I key in the value of a cell. help!
- Use custom Javascript for a custom Elementor Widget [closed]