Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(javascript / else / noscript iframe) to reduce server processing?

On my website I serve a retail inventory catalog. I want to place the burden of data processing and rendering the inventory on the client browser, to reduce my server side processing and bandwidth. I also want the content to be bot-crawlable.

I'm imagining it like this, but I'm wondering if there is a better solution:

1: If javascript is enabled, process the data client side

2: If javascript is not enabled, process the data server side:

<noscript>
<iframe>
php processing script
</iframe>
</noscript>

Also, please confirm that the iframe will not be loaded if Javascript is enabled. If the browser processes it anyway, then that defeats my goal.

Lastly, please confirm that google bot will crawl the iframe. I want the iframe to be indexed as part of the loading page, not a separate page. The iframe is loaded from a completely separate domain, so I'm worried that google might not index it at all.

Thanks, Skibulk

like image 712
skibulk Avatar asked Nov 13 '22 14:11

skibulk


1 Answers

please confirm that the iframe will not be loaded if Javascript is enabled

The decision whether to display the <noscript> content is taken by the browser. This means you will still be processing and downloading the result of your "php processing script" whether or not the client decides to show it.

Really, you would have to have an iframe that points to a source page, so it will only be loaded if the client decides the <noscript> block should be shown.

<noscript>
    <iframe src="yourserverpage"></iframe>
</noscript>

please confirm that google bot will crawl the iframe. I want the iframe to be indexed as part of the loading page, not a separate page

Sadly this isn't possible.

You can still have a page on your server that displays the content, but it will be indexed at its correct address, not as part of the page you embed the iframe in. For example, imagine this is the HTML for "PageA"

<noscript>
    <iframe src="PageB"></iframe>
</noscript>

The content inside this iframe will be indexed at PageB, not as part of PageA.

You could fix this in some cases by using the canonical meta tag:

<link rel="canonical" href="PageA">

When placed in the <head> of your HTML page, this tag requests crawlers to index the content under a supplied alternative address. This is usually used when the same content appears on both pages, but you want one to be the master for search results. I don't know if using it in your context may be considered "black-hat" by crawlers as the context is subtly different.

An alternative approach!

If you have a large inventory, you may be better off introducing the concept of paging the results. You could then have a working non JavaScript page with links to further pages of inventory. You could then use JavaScript to intercept the paging action and use an alternative method to get the results if you think it adds value to people visiting your website.

like image 196
Fenton Avatar answered Nov 16 '22 04:11

Fenton