Mobile app version of vmapp.org
Login or Join
Angela700

: Can generating static links via javascript be legal and recognized? I have a page of photo thumbnails on my site. On the page, a large number of links are grouped together consecutively, and

@Angela700

Posted in: #Anchor #Javascript #Links #StaticContent

I have a page of photo thumbnails on my site. On the page, a large number of links are grouped together consecutively, and the links take up at least 1/2 the HTML code size.

Here's an example:

<div>
<a href="1">1</a>
<a href="2">2</a>
<a href="3">3</a>
<a href="4">4</a>
....
<a href="50">50</a>
</div>


What I'm thinking to significantly reduce code size from about 20 bytes per link (which equals 10KB for pages with 500 links) to maybe a few dozen bytes total is to generate the links via javascript like this:

<div ID="links"></div>
<script>
var div=document.getElementById("links");
for (n=1;n<=50;n++){
var anchor=document.createElement("A");
anchor.href=n;
anchor.innerHTML=n;
div.appendChild(anchor);
}
</script>


I did read at support.google.com/webmasters/answer/2721306 that automatically generated content is a bad idea but at the same time I'm trying to make users download fewer bytes.

My question is would search engines understand that I'm trying to produce actual static links with this code? and would all search engines consider this code legal, or would any search engine flag me? And we need to look at the buggy aspects of google because I don't want a robot to flag my account for generating static links via javascript.

The only reasons I'm looking into this is because I could cut my code size by at least 1/2 and also because I'm providing a static (non javascript-based link) on the same page that will allow guests to see content the javascript generated anchor tags link to.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cooney921

Automatically generated content is not the same as programmatically generated markup. The Google guideline you linked to does not relate to the change you're proposing.

Whilst I'm all for improving site speed, you should really focus things that will actually make a difference. You've said in other questions that your HTML pages are served gzipped - shaving a few kilobytes of HTML markup from a gzipped page is a miniscule amount that will have little effect on the time it takes the page to download. Also, if your markup is really that repetitive, you might find that the HTML-only version is smaller gzipped than the javascript version, since it will compress better.

Since you seem concerned about how search engines view your site, making it harder for them to index your content (by dynamically generating it client side) would seem like a bad approach. (And if you have a non-js version of this markup on the page anyway, why do you need both?)

Post a webpagetest.org report for the page you're trying to improve (perhaps in chat), and I'm sure we can suggest some better things for you to look at. There are good tools for measuring and monitoring site speed, so you don't need to guess at what might help.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme