Forum Moderators: open

Message Too Old, No Replies

Facebook code at the bottom

         

toplisek

8:35 pm on Oct 17, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have seen that Facebook posted demand to place javascript code under body.


I have seen website using above /body. So, at the end.

<script>(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 = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

</body>

Can be this done actually?

mw11

9:05 pm on Oct 19, 2014 (gmt 0)



I'm not sure what your question is. Could you rephrase your question?

To put it differently, what is it that you would like to accomplish? You would like to see A) an image, such as a Faceboook logo? Or B) a link to a specific Facebook page? Or C) something else?

On the positive side, what is clear is the location. You want 'it' just before the 'end' of the 'body' section.

lucy24

12:16 am on Oct 20, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



to place javascript code under body

Do you mean at the very end of the <body> element, as opposed to inside the <head> element?

The generic rule for scripts is: put them as late as possible, so the page doesn't have to load them before it can render. Some specific scripts have to come earlier or they won't work. A lot of the time, it's faster just to try a few locations-- making sure to empty the browser cache in between-- and see for yourself.

toplisek

7:34 am on Oct 21, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sorry if I was not clear. Usually all social marketing pages use Async.

So, check
[developers.facebook.com...]

Placement:
1. Include the JavaScript SDK on your page once, ideally right after the opening <body> tag.
2. Place the code for your plugin wherever you want the plugin to appear on your page.

I have added async=true;.
question is the following: Where to place code number 1? Is there any solution to avoid this code and use also other social pages like twitter?