WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
[resolved] Prevent JetPack from adding JS to Website (5 posts)

  1. edtalmadge
    Member
    Posted 8 months ago #

    Currently, JetPack adds several JavaScript items to a website's webpages (ex = jquery, gravatar, etc).

    Is there a way to prevent this from occurring?

    My goal is to prevent JetPack from adding any JavaScript to the page.

    Now, when I use JetPack to connect my self-hosted blog to my WordPress.com account, JetPack is adding a lot of html, css and JavaScript to the page.
    The result is that my existing scripts are breaking.

    I want to use JetPack only to connect to my WordPress.com account. I do not want to use any other features. So, in my case, there is no reason for JetPack to add JavaScript to my webpages.

    How can I prevent JetPack from adding JavaScript to my website?

    http://wordpress.org/plugins/jetpack/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 8 months ago #

    I want to use JetPack only to connect to my WordPress.com account. I do not want to use any other features. So, in my case, there is no reason for JetPack to add JavaScript to my webpages.

    I'm not sure I understand why you need to connect Jetpack to your WordPress.com account if you don't plan on using any of the features in the plugin. Could you let me know what you'd like to achieve by connecting Jetpack to your WordPress.com account?

    Thanks!

    Currently, JetPack adds several JavaScript items to a website's webpages (ex = jquery, gravatar, etc).
    Is there a way to prevent this from occurring?

    You can dequeue resources from being loaded on a WordPress site thanks to the wp_dequeue_script (#) and wp_dequeue_style(#) functions

    Here are an example, to remove the devicepx file used to optionally load retina/HiDPI versions of files (Gravatars etc) which are known to support it:

    function tweakjp_dequeue_devicepx() {
    wp_dequeue_script( 'devicepx' );
    }
    add_action( 'wp_enqueue_scripts', 'tweakjp_dequeue_devicepx', 20 );
  3. edtalmadge
    Member
    Posted 8 months ago #

    Thanks Jeremy.

    What I'd like to achieve by connecting JetPack account to my WordPress.com account is to link a WordPress self hosted account to a Klout.com account.

    For example:
    1. Add JetPack to self-hosted blog.
    2. Use JetPack to connect self-hosted blog to WordPress.com account.
    3. Use Klout control panel to link Klout Account to WordPress.com account (and self-hosted WordPress website)

    The process is outlined here:
    http://www.kimberlyblack.com/klout-and-wordpress/

    Thanks for your suggestion about wp_dequeue_script.

    How do I figure out all the scripts that need to be dequeued?
    Is it just a matter of viewing html page source and add a new "add_action" statement (for each linked js file) to functions.php with the first argument as the name of the js file?

    I'm not sure if this is a great idea.
    For example, let's say I dequeue all scripts today. Then tomorrow a new JetPack script is added. At this point a script could be added to my blog, right? Please let me know if that's incorrect.

    I was hoping for a JetPack setting like "don't add CSS and JavaScript"

  4. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 8 months ago #

    What I'd like to achieve by connecting JetPack account to my WordPress.com account is to link a WordPress self hosted account to a Klout.com account.

    Thanks, that makes sense.

    If you disable each Jetpack module, you will only have to dequeue the one script I mentioned in my last post: all other scripts are automatically deactivated when you disable the related module.
    You can follow the instructions here to learn how to deactivate a Jetpack module:
    http://jetpack.me/support/#turn-off-jetpack-modules

    For example, let's say I dequeue all scripts today. Then tomorrow a new JetPack script is added. At this point a script could be added to my blog, right? Please let me know if that's incorrect.

    You can add this code to your theme's functions.php to make sure that all new Jetpack modules are deactivated by default:
    add_filter( 'jetpack_get_default_modules', '__return_empty_array' );

  5. edtalmadge
    Member
    Posted 8 months ago #

    Thanks Jeremy, I followed the instructions to disable the JetPack modules and added the filter to functions.php.

    It worked!
    JetPack is enabled & connected and no more JS errors on the blog.

Reply

You must log in to post.

About this Plugin

About this Topic