Title: Exclude Scripts in functions.php
Last modified: November 18, 2020

---

# Exclude Scripts in functions.php

 *  [diesignatur](https://wordpress.org/support/users/diesignatur/)
 * (@diesignatur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/)
 * Hey there,
    what an awesome plugin it works like a charme beside one thing: I
   used the following script for the functions.php
 *     ```
       add_filter('wp_print_scripts', function () {
           wp_script_add_data('pdfemb_embed_pdf_js-js-extra', 'phast_no_defer', true);
           wp_script_add_data('pdfemb_embed_pdf_js-js', 'phast_no_defer', true);
           wp_script_add_data('pdfemb_pdf_js-js', 'phast_no_defer', true);
       	wp_script_add_data('jquery-core-js', 'phast_no_defer', true);
       });
       ```
   
 * But the scripts are still used with phastpress. Can you help?

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [Albert Peschar](https://wordpress.org/support/users/kiboit/)
 * (@kiboit)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13676995)
 * Hey [@diesignatur](https://wordpress.org/support/users/diesignatur/),
 * Thanks for trying out PhastPress!
 * The `-js` and `-js-extra` are not part of the script IDs. If you remove them,
   I think your code should work:
 *     ```
       add_filter('wp_print_scripts', function () {
           wp_script_add_data('pdfemb_embed_pdf_js', 'phast_no_defer', true);
           wp_script_add_data('pdfemb_pdf_js', 'phast_no_defer', true);
           wp_script_add_data('jquery-core', 'phast_no_defer', true);
       });
       ```
   
 * If that doesn’t help, please let me know. 🙂
 * And if PhastPress is working well for you, I’d really appreciate it if [you left a review here](https://wordpress.org/support/plugin/phastpress/reviews/#new-post).
 * –Albert
 *  Thread Starter [diesignatur](https://wordpress.org/support/users/diesignatur/)
 * (@diesignatur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13678280)
 * Hey Albert,
 * thanks for your fast reply. I used the function like this and it seems to work:
 *     ```
       add_filter('wp_print_scripts', function () {
           wp_script_add_data('pdfemb_pdf_js', 'phast_no_defer', true);
       	wp_script_add_data('pdfemb_embed_pdf_js', 'phast_no_defer', true);
       });
       ```
   
 * But unfortunately it doesnt solve my problem. Since activating PhastPress the
   Plugin “PDF Embed” is not working anymore, so I am trying to exclude it, but 
   for now without any success. Do you have any idea what I am doing wrong? You 
   can see the result here: [https://wp-pdf.com/kb/setting-up-fake-worker-failed-error-message/](https://wp-pdf.com/kb/setting-up-fake-worker-failed-error-message/)(
   the PDF should be embedded but there is only a link now after activating phastpress)
 * The Plugin developer has a site about caching-plugins and related errors here:
   [https://wp-pdf.com/kb/setting-up-fake-worker-failed-error-message/](https://wp-pdf.com/kb/setting-up-fake-worker-failed-error-message/)
   Maybe this helps for your “investigation”.
 * I have already unchecked the “Remove query string from processed resources ” 
   setting in phastpress.
 * FYI: If I uncheck “Load scripts asynchronously” and “Minify scripts and improve
   caching ” in my tests the plugin works.
    -  This reply was modified 5 years, 6 months ago by [diesignatur](https://wordpress.org/support/users/diesignatur/).
    -  This reply was modified 5 years, 6 months ago by [diesignatur](https://wordpress.org/support/users/diesignatur/).
 *  Plugin Author [Albert Peschar](https://wordpress.org/support/users/kiboit/)
 * (@kiboit)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13678568)
 * Hi [@diesignatur](https://wordpress.org/support/users/diesignatur/),
 * I’ve tested with PDF Embedder and found the issue. This plugin uses the pdf.js
   library, which uses the `document.currentScript` variable to find the URL to 
   itself. This was not yet supported by PhastPress’ script optimizer.
 * I’ve just released PhastPress 1.88 which fixes this problem. After updating to
   this version, it should work fine.
 * You can remove your custom filter, it is no longer needed. Also, you can enable“
   Remove query string from processed resources” and other disabled options, these
   are now all compatible with PDF Embedder.
 * Let me know if this update resolves your issue or if you have any other concerns.
 * –Albert
 *  Thread Starter [diesignatur](https://wordpress.org/support/users/diesignatur/)
 * (@diesignatur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13678710)
 * Works like a charm Albert. And outstanding fast support! This is by far the best
   Pagespeed Optimization Plugin for WordPress and I am quite experienced with Page
   Speed Optimizations for WordPress over the years.
 * The only problem now is that as soon as I turn on WP-Super-Cache its gone again
   😛
 *  Plugin Author [Albert Peschar](https://wordpress.org/support/users/kiboit/)
 * (@kiboit)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13678716)
 * Hey [@diesignatur](https://wordpress.org/support/users/diesignatur/),
 * PhastPress should be compatible with WP Super Cache.
 * Have you cleared your WP Super Cache cache after activating/configuring PhastPress?
 * –Albert
 *  Thread Starter [diesignatur](https://wordpress.org/support/users/diesignatur/)
 * (@diesignatur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13678727)
 * Yes I cleared the cache before re-activating a few times already. everything 
   else beside the PDF embedder works fine.
 *  Plugin Author [Albert Peschar](https://wordpress.org/support/users/kiboit/)
 * (@kiboit)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13678868)
 * Hi [@diesignatur](https://wordpress.org/support/users/diesignatur/),
 * Very strange. It must be due to caching somehow.
 * Would you be able to share the URL to your site with me? If you don’t wish to
   post it publicly, you can find my contact details at the bottom of the plugin
   description.
 * –Albert
 *  Thread Starter [diesignatur](https://wordpress.org/support/users/diesignatur/)
 * (@diesignatur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13679331)
 * Hey Albert, I just sent you the mail and activated the wp super cache again
 *  Plugin Author [Albert Peschar](https://wordpress.org/support/users/kiboit/)
 * (@kiboit)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13679527)
 * Hi [@diesignatur](https://wordpress.org/support/users/diesignatur/),
 * I’ve tested with WP Super Cache and it seems that the issue is triggered when
   you have selected “Expert” mode and also enabled the “Late init” option.  In 
   that case PhastPress optimizations were not stored in the cache, and thus only
   effective on the first (uncached) pageload.
 * I’ve just released version 1.89 which should fix this problem.
 * Please try it out and let me know.  🙂
 * –Albert
 *  Thread Starter [diesignatur](https://wordpress.org/support/users/diesignatur/)
 * (@diesignatur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13679609)
 * Hi Albert,
 * I have just updated to the new version and cleared the cache but the result as
   you can see is still the same.
 * My settings are “simple mode” and “late init” on.
 * BTW: When I switch off “late init” it works.
    -  This reply was modified 5 years, 6 months ago by [diesignatur](https://wordpress.org/support/users/diesignatur/).
 *  Plugin Author [Albert Peschar](https://wordpress.org/support/users/kiboit/)
 * (@kiboit)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13681885)
 * Hi [@diesignatur](https://wordpress.org/support/users/diesignatur/),
 * The final issue is caused by the [NextGEN Gallery](https://wordpress.org/plugins/nextgen-gallery/)
   plugin on your site.
 * It uses some logic to reorder scripts and stylesheets which is not compatible
   with PhastPress and WP Super Cache late init. So one solution is to disable late
   init, but if you need it on your site, that won’t help.
 * So I’ve now released PhastPress 1.90 with a workaround for this issue. It makes
   sure that the NextGEN Gallery resource manager doesn’t conflict with PhastPress.
 * You can install it and let me know if it fixes the issue. 🙂
 * –Albert
 *  Thread Starter [diesignatur](https://wordpress.org/support/users/diesignatur/)
 * (@diesignatur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13683345)
 * Works like a charm Albert. Outstanding support thank you very much!

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Exclude Scripts in functions.php’ is closed to new replies.

 * ![](https://ps.w.org/phastpress/assets/icon-256x256.png?rev=1873505)
 * [PhastPress](https://wordpress.org/plugins/phastpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/phastpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/phastpress/)
 * [Active Topics](https://wordpress.org/support/plugin/phastpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/phastpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/phastpress/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [diesignatur](https://wordpress.org/support/users/diesignatur/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/exclude-scripts-in-functions-php/#post-13683345)
 * Status: not resolved