5

Most sources of documentation state that one can declare a webpage a duplicate of another by applying this tag on the duplicate page:

<link rel="canonical" href="(absolute URL to original page)">

I could generate the above tag via the script below:

<script>
var l=document.createElement('Link');
l.rel='canonical';l.href='(absolute URL to original page)';
document.getElementsByTagName('head')[0].appendChild(l);
</script>

My question is, would google be able to process this javascript and believe I'm declaring the page as a duplicate page? or would I be forced to use the link tag in the header?

I ask because I'm trying to reduce the unnecessary bytes required to be processed before the actual user readable content begins.

  • 1
    Am I missing something?? It seems that the link is smaller than the JS. – closetnoc Dec 18 '15 at 0:09
  • 1
    I am not sure where you saw that, but I cannot imagine how that is soooooo true. Of course you want their code processed sooner, but I would just move it up as far as I can, but not worry about it otherwise. I guess I should check where my G JS is... just might be at the end of my HTML!! ;-) Ooopppsss! – closetnoc Dec 18 '15 at 0:58
  • 1
    Here's a source claiming google pays more for sites whose adsense block is closer to the beginning in the HTML code: techwelkin.com/important-tip-first-adsense-ad-matters-a-lot – Mike -- No longer here Dec 18 '15 at 4:53
  • 1
    Yes. That is true. My top most ad always gets clicked on more and gets the higher revenue, but that is because it is the most desirable size (big) placed high on the page and therefore in the users face - so to speak. His theory is that you can manage which ad gets the higher CPM by using a div and placing the it anywhere on the page using CSS, however, this can be hard to manage with absolute positioning. I use divs too, but I just put them where I want them. I am not sure I would be working as hard as he is recommending. It might work for you though. – closetnoc Dec 18 '15 at 5:31
  • 1
    That adsense article is about having your adds as early as possible in the <body>. I don't see how removing a line of HTML code from the <head> is going to make any difference to your ad revenue. – Tim Fountain Dec 18 '15 at 11:07
0

Firstly the use of canonical:

The use of canonical is not exactly creating duplicate pages. Every application should avoid creating duplicate pages.
1)Canonical is meant to give seo wieghtage to the main or parent page from which it is derived.

2)This needs not to be exact duplicate, but this means this new page is also generating similar information with the canonical.

3) This is lot used in blogging/news sites where i want to publish content from other sources to my site and give credits to the actual owner

4) Also used in cases like running a site on both http and https and you take one of them as base for seo crawling. So you add that to another as canonical.

Other useful cases as well exists which make canonical a very important tag and should be used carefully

Adding Canonical via javascript

Though google crawlers are now becoming intelligent enough to understand javascript. But this should be done with best implementation practices and recommendations, otherwise you end up messing with your seo health. As if google does not read canonical properly, you end up penalizing for duplicate content.

https://developers.google.com/webmasters/ajax-crawling/docs/learn-more

Unnecessary content for user, saving space - Useless in described case

The required seo tags don't add up that much which will hurt you front-end performance or help reducing network transfer time.

Yes if you want to tune your page such that you pass all crawler related + most important components of your site in first load, and then load content on demand via ajax then you should go ahead but following best practices if you want that content to be seo friendly.

But for canonical addition via javascript just to save few bytes of transfer is not recommended.

| improve this answer | |
0

yes, Google is able to proceed Javascript, even if it fires after onload, if you add your script on the bottom of the file and add something like window.addEventListener('load', l);.

placing the adsense code closer to the beginning of the HTML code means more money

In my opinion, the plan is useless, because your page with duplicated content will never get good AdSense scoring, even if you make the distance from the page beginning to the AdSense one code line shorter.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.