Google’s John Mueller responded to an SEO seeking advice regarding issues with canonicals and the use of angular JavaScript.
In a Reddit thread, the SEO writes:

“For thousands of pages on the site Google is ignoring the canonical link and selecting their own, the issue is the page Google is selecting is incorrect.”

Mueller responded saying, when it comes to canonicals, Google asks itself: “Are these URLs for the same content?”
If the URLs are not for the same content, why might Google think that they are?
Usually the answer falls into one of two categories:
They return mostly the same content to Google
The URL structure is so messy that Google can’t efficiently check them all and has to guess
Mueller addresses this issue specifically as it relates to JavaScript:

“With JavaScript based sites, the content side is a common reason for this: for example, if you’re using a SPA-type setup where the static HTML is mostly the same, and JavaScript has to be run in order to see any of the unique content, then if that JS can’t be executed properly, then the content ends up looking the same.”

There are multiple reasons why JavaScript might not be executed properly, Mueller says.
Possible reasons for JS not being executed properly include:
“Flakey” code
Sometimes it doesn’t degrade gracefully
Sometimes resources (JS-files) or server responses (API requests, etc) are blocked by robots.txt
Sometimes the JS just takes too long to process
If the code works for Googlebot, which can be determined with the mobile-friendly test, then it’s worth estimating if the speed of processing might be an issue.
Mueller adds that the hard part with that is there’s no absolute guideline or hard cut-off point to test for.
Also, a page rarely loads exactly the same way across separate tests.
With that in mind, Mueller provides the next bit of advice:

“My way of eyeballing it is to see how long the mobile-friendly test roughly takes, and to check with webpagetest.org to see how long a page might take to load the critical / unique content, and how many resources are required to get there. The more resources required, the longer time until the critical content is visible, the more likely Google will have trouble indexing the critical content.”

So, what Mueller ultimately thinks is happening to the SEO in the Reddit thread, is that Google sees their two pages as serving mostly the same content.
That’s a sign that Google can’t pick up the unique content on each page.
Further, it’s a sign that it may be too hard to get to the unique content.
It may be too hard for Google to get to the unique content because it takes too many requests to load.
Or the responses take too long to get back, so the focus stays on the boilerplate HTML rather than the JS-loaded content.
Lastly, Mueller says that reducing dependencies and latency can help solve that issue.

Subscribe to SEJ
Get our daily newsletter from SEJ’s Founder Loren Baker about the latest news in the industry!

Call Now ButtonCall Now!