WordPress.org

Ready to get started?Download WordPress

Forums

Facebook
[resolved] disable facebook loading if responsive view (2 posts)

  1. Iamhere
    Member
    Posted 11 months ago #

    Hi

    I would like to know if there is any suggested method to disable the loading of the Facebook JS if the page is being viewed on small screens.

    It takes a lot of bandwidth to load it up!

    I appreciate this would be easier on a mobile site, but I am using responsive media queries.

    Is there any way to disable JS on a screen size basis, like you can with CSS ?

    Thanks

    http://wordpress.org/plugins/facebook/

  2. Niall Kennedy
    Member
    Plugin Author

    Posted 11 months ago #

    Two issues:

    • Preventing the Facebook SDK for JavaScript from downloading and saving the bandwidth in the process
    • Facebook SDK for JavaScript loads but you would like to disable some or all social plugins.

    In your JavaScript you are probably computing the size of the currently available viewport and making some decisions based on the size, similar to a CSS media query. If width 480 pixels or less do not load these JavaScript.

    The Facebook SDK for JavaScript loads asynchronously through wp_enqueue_script in the footer. The asynchronous JavaScript checks for the existence of a facebook-jssdk DOM ID on the page and assumes the JavaScript file has already been loaded if found. Adding your own element with the ID of facebook-jssdk would short-circuit this loader and fbAsyncInit() would not be called.

    If you would like greater control over when or if social plugins load on the page set the xfbml value passed in the facebook_jssdk_init_options WordPress filter to false and call FB.XFBML.parse on a parent of the social plugin element parent directly.

Reply

You must log in to post.

About this Plugin

About this Topic