Support » Plugin: Facebook » disable facebook loading if responsive view

  • Resolved Iamhere



    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 ?


Viewing 1 replies (of 1 total)
  • Plugin Author Niall Kennedy


    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.

Viewing 1 replies (of 1 total)
  • The topic ‘disable facebook loading if responsive view’ is closed to new replies.