Third party NoScript causing error on Facebook Open Graph Object Debugger

owls8521

Active member
When I put one of my urls into the Facebook Open Graph Object Debugger, I received the following error:
Your page has meta tags in the body instead of the head. This may be because your HTML was malformed and they fell lower in the parse tree. Please fix this in order for the tags to be usable.

I found that the following line in PAGE_CONTAINER was causing the issue:
Code:
<noscript><style>.JsOnly, .jsOnly { display: none !important; }</style></noscript>

I solved it by moving that line to right before the closing head tag. If you do not do that, Facebook will close the head tag early.
 
Last edited:
At the moment, this isn't reproducible.

For it to be considered a bug, it would need to be something that could be reproduced reliably on the default XF style. In fact, I've just tried it on a number of sites (including this one) and other sites that use custom styles, and none of them report the same issue.

This would lead me to believe, in fact, that there could be some other problem in your template.

All that being said, the HTML is valid, and <noscript> is not considered to be a meta tag, so the error from Facebook makes very little sense.

If you would be able to put the code back where it was, I'll happily do a bit more testing to see if we can make a bit more sense as to what's going on.
 
I just tested it on this page. To reproduce:
  1. Go to Facebook Open Graph Object Debugger
  2. Enter https://xenforo.com/community/threads/noscript-causing-error-on-facebook-open-graph-object-debugger.91232/ into the box.
  3. Click the Fetch new scrape information button
  4. See the error that appears
The following screenshot shows I'm using this url.

Screen Shot 2015-01-20 at 4.04.29 PM.webp

For even more information, click the link at the bottom of the page that says See exactly what our scraper sees for your URL.

Here's the beginning of the output:
<!DOCTYPE html>
<html id="XenForo" lang="en-US" dir="LTR" class="Public NoJs GalleryLazyLoader LoggedOut NoSidebar Responsive" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="https://xenforo.com/community/">
<script>
var _b = document.getElementsByTagName('base')[0], _bH = "https://xenforo.com/community/";
if (_b && _b.href != _bH) _b.href = _bH;
</script><title>Awaiting Feedback - NoScript causing error on Facebook Open Graph Object Debugger | XenForo Community</title>
</head>
<body>
<noscript><style>.JsOnly, .jsOnly { display: none !important; }</style></noscript>
Notice the closing head tag appears right before the noscript tag.
 
This looks like a bug in the FB tool to me. It has randomly rewritten some of the HTML in ways that we certainly aren't outputting (changed tabs/line breaks, HTML tags changing structure). It's actually even added a line that isn't in the HTML (the opening <meta> tag).
 
This looks like a bug in the FB tool to me. It has randomly rewritten some of the HTML in ways that we certainly aren't outputting (changed tabs/line breaks, HTML tags changing structure). It's actually even added a line that isn't in the HTML (the opening <meta> tag).
Now we have to wait Facebook fix this bug? Or any temporary solution for this bug?
 
I would recommend reporting it to Facebook if it is affecting you. They won't fix it unless there are reports of it happening.

You could modify your templates as described in the first post, but really this should not be necessary and counter productive if you do end up reporting it to Facebook (they'll likely want to see a reproduction of the bug). Our HTML is valid. I think Facebook is doing something weird to force the HTML to be valid based on old standards. I believe <noscript> tags were previously invalid in <head> in earlier HTML specs. In HTML5, though, it is perfectly valid and passes various validation tests.
 
This looks like a bug in the FB tool to me. It has randomly rewritten some of the HTML in ways that we certainly aren't outputting (changed tabs/line breaks, HTML tags changing structure). It's actually even added a line that isn't in the HTML (the opening <meta> tag).
It's happening with all of our pages too; as of 1.4.4 I believe.

It's definitely Facebook bug that takes issue with the <noscript> tag placement. If you move it just before </head> the Facebook Open Graph Object Debugger will move it to the first line after the <body> tag and the errors will cease.

It's not ideal, but moving the <noscript> line out of the <head></head> will act as a temporary workaround.
 
Last edited:
It's happening with all of our pages too; as of 1.4.4 I believe.

It's definitely Facebook bug that takes issue with the <noscript> tag placement. If you move it just before </head> the Facebook Open Graph Object Debugger will move it to the first line after the <body> tag and the errors will cease.

It's not ideal, but moving the <noscript> line out of the <head></head> will act as a temporary workaround.
I try to mote <noscript> before </head> but the errors is cseased. But this change can affect my forum? Example affect search engine? I'm not a coder.
 

Attachments

  • 2015-01-21_111856.webp
    2015-01-21_111856.webp
    72.2 KB · Views: 19
Same problem over here.

Facebook also does not recognize the correct og:image size.
I use a 512x512 PNG image but the FB URL Linter says that it is too small (under 200px).

I hope they fix it very soon :confused:
 
Top Bottom