Title: Blocking FB sdk
Last modified: January 25, 2018

---

# Blocking FB sdk

 *  Resolved [humanify](https://wordpress.org/support/users/humanify/)
 * (@humanify)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/blocking-fb-sdk/)
 * Hello!
 * I’ve found that using autoptimize blocks the use of the [Facebook SDK for Open Graph](http://www.fbrell.com/Sharing/2%20-%20FB.ui%20Dialogs)
   share dialog. Especially on iOS devices.
 * Apparently its the ‘optimize html code’ option that causes this problem.
 * For now i’ve turned this off. I wonder if there’s any way around this?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fblocking-fb-sdk%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/blocking-fb-sdk/#post-9902355)
 * how does it block [@humanify](https://wordpress.org/support/users/humanify/)?
   what should it do and what does it do instead? do you see errors? do you know
   what specifically in the HTML causes the breaking?
 *  Thread Starter [humanify](https://wordpress.org/support/users/humanify/)
 * (@humanify)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/blocking-fb-sdk/#post-9902415)
 * Hi, thanks for quick response!
 * First off. I’m not a huge techie in this regard. I’ve added the Facebook SDK 
   in my webpage header, and added a button in my content.php (part of my template).
   According to the example that I added in the first link above. I deviated from
   the example by chaning the href to `window.location.href` to call the actual 
   page URL.
 * When I installed autoptimize, the share button stopped working. I’ve tried turning
   off each of the Autoptimize options to see what caused it. Turns out that only
   turning off HTML optimization made it appear again. Leaving CSS and JS on does
   not create problems.
 * _What should it do?_
    It should open the facebook OpenGraph dialog to share the
   current page. Current behavior is that it loads the dialog in a new tab.
 * _What does it do instead?_
    When HTML optimization is turned on: the button activates,
   but does not load anything.
 * I do not know what specifically cause the breaking. But I suspect its the facebook
   scripts paired with the button in the content.php which generates the html.
 *  Thread Starter [humanify](https://wordpress.org/support/users/humanify/)
 * (@humanify)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/blocking-fb-sdk/#post-9902433)
 * Quick follow up. I’ve now turned HTML optimization back ON, so you could maybe
   have a look. [Here is a
    page with the button.
 * Please note, to clarify. It does only NOT work on IOS devices, like my Iphone
   7 or Ipad. It works fine on Chrome or Firefox
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/blocking-fb-sdk/#post-9903068)
 * OK, can you try to enclose the changes you made in your content.php in noptimize-
   tags, making sure the HTML output is something like this;
 *     ```
       <!--noptimize-->
       <your code goes here>
       <and here>
       <and whatnot>
       <!--/noptimize-->
       ```
   
 * frank
 *  Thread Starter [humanify](https://wordpress.org/support/users/humanify/)
 * (@humanify)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/blocking-fb-sdk/#post-9905436)
 * Hi Frank,
 * Thanks for the help! Using the noptimize tags for the Facebook SDK script in 
   the header.php solved the problem.
 * (After some testing, the parts in the content.php work fine without.)
 * For your reference, this is the part, right after the body opening tag:
 *     ```
       <!--noptimize-->		
       <script><!-- facebook SDK script -->
         window.fbAsyncInit = function() {
       	FB.init({
       	  appId            : '-----------',
       	  autoLogAppEvents : true,
       	  xfbml            : true,
       	  version          : 'v2.11'
       	});
       	  FB.AppEvents.logPageView();
         };
   
         (function(d, s, id){
       	 var js, fjs = d.getElementsByTagName(s)[0];
       	 if (d.getElementById(id)) {return;}
       	 js = d.createElement(s); js.id = id;
       	 js.src = "https://connect.facebook.net/en_US/sdk.js";
       	 fjs.parentNode.insertBefore(js, fjs);
          }(document, 'script', 'facebook-jssdk'));
       </script><!-- END facebook SDK script -->
       <!--/noptimize-->
       ```
   
    -  This reply was modified 8 years, 4 months ago by [humanify](https://wordpress.org/support/users/humanify/).
    -  This reply was modified 8 years, 4 months ago by [humanify](https://wordpress.org/support/users/humanify/).
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/blocking-fb-sdk/#post-9905530)
 * super [@humanify](https://wordpress.org/support/users/humanify/), fijn weekend
   gewenst! 🙂

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

The topic ‘Blocking FB sdk’ is closed to new replies.

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

 * 6 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/blocking-fb-sdk/#post-9905530)
 * Status: resolved