I wanted to confirm that this script is responsible for the resources:
If not, what scripts are they?
How can I dequeue this script?
This way it didn’t work:
function remove_scripts_instantpage_conditionally() {
$pages_to_remove = array('service', 'service/thank you');
if (is_page($paginas_para_remover)) {
wp_dequeue_script('swcfpc_instantpage-js');
}
}
add_action('wp_enqueue_scripts', 'remove_scripts_instantpage_conditionally', 0);
thx
]]>I have disabled a but a very few blocks for my site: Image, paragraph, list, quote, image. Basically the blocks that are available here in the WordPress Forums.
I am trying to pull my main stylesheet into the editor as an editor stylesheet, so my front and back ends match. I don’t want to fight with the built-in block editor styles, either on the front or the back end. I just want them removed.
How do I dequeue/deregister/disable block editor styles from the admin?
]]>I want to load the plugin only on the page that has the subscribe button. Would it be possible to hook into this?
function dequeue_email_subscribers() {
if (!is_page(‘subscribe-now’)) {
wp_dequeue_script(’email-subscribers-script-handle’);
wp_dequeue_style(’email-subscribers-style-handle’);
}
}
add_action(‘wp_enqueue_scripts’, ‘dequeue_email_subscribers’, 100);
We have partially covered this topic here and here.
After careful evaluation, once again, we need to ask you a favor. We need a code snippet that will help us dequeue and deregister your “dynamic” JS files (e.g.,/jc.js
and /base.js
) on mobile devices and tablets for your new plugin version, V3.+
Based on one of your previous comments, we don’t see a need for the dynamic JS files (nor corresponding dynamic data-handles) since the odds for a website to have more than one language selector on one page is practically nil.
So, in short, it would be awesome if you can update your plugin’s code to help with this request. Yours is the only plugin that we know of that uses dynamic JS files (i.e., data-handles). Heck, it didn’t before V3.+!
If you can change them to them to static, we can easily dequeue and deregister your JS files with the PHP code snippet provided below, which we already use for other plugins.
add_action( 'wp_print_scripts', 'dequeue_unnecessary_scripts' );
function dequeue_unnecessary_scripts() {
if(window.innerWidth < 760) {
wp_dequeue_script( 'js-data-handle-1' );
wp_deregister_script( 'js-data-handle-1' );
wp_dequeue_script( 'js-data-handle-2' );
wp_deregister_script( 'js-data-handle-2' );
}
}
As you know, every bit of payload saved helps improve website performance.
Here’s a great corollary:
"Even the greatest ships can sink one leak at a time." -- Thomas A. Edison.
Thanks for reading. Thanks for your help!
]]>Three months ago, you provided the JS code noted below to dequeue your plugin’s assets on mobile devices. The JS code was for your plugin, V2.9.5. Is it still valid for V3.0.1?
We performed a couple of tests. Results were inconclusive.
Thank you!
<script>
if(window.innerWidth < 760)
window.gt_translate_script = true;
</script>
]]>So, my question is what are the WP recommended best practices for when and how best to dequeue styles/scripts, both if you’re working with a child theme and not. I would like to make sure that i do this by the book.
thank you!
]]>I would like to stop the loading of external files, because in Europe this can have legal consequences without the user’s consent.
Your plugin is great and I use it regularly. However, with the Lightbox variant “Fancybox” it loads a file from the CDN “cdn.cloudflare”:
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/jquery-browser/0.1.0/jquery.browser.min.js?ver=3.30' id='fancybox-0-js'></script>
Since I am embedding this file locally, I would like to avoid this external source.
The following two attempts have been unsuccessful so far:
function dequeue_footer_jquery() {
wp_dequeue_script( 'fancybox-0' );
wp_deregister_script('fancybox-0');
}
add_action( 'wp_print_scripts', 'dequeue_footer_jquery', 100 );
function mywptheme_child_deregister_script() {
wp_dequeue_script( 'fancybox-0' );
wp_deregister_script('fancybox-0');
}
add_action( 'wp_enqueue_scripts', 'mywptheme_child_deregister_script', 100 );
Please be so kind and give me a short instruction how to solve the problem.
Thank you in advance!
Jomi
Can someone please explain how this is best done.
]]>