Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryWeb Page and Site Optimization

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Search Engine Spider-Friendly JavaScript Content

If you have syndicated content delivered with JavaScript, the content might not be indexed by the search engines.

Syndicated content, in this article, means HTML content (text, images, forms, and so forth) delivered from a remote site and published on your page with JavaScript code similar to:

<script 
   language="JavaScript" 
   src="https://example.com/file.js">
</script>

If you syndicate the Possibilities articles, you're familiar with the above. The software used to prepare and deliver JavaScript syndicated content is Master Syndicator V4 from https://www.willmaster.com/software/syndicator/ or Master Syndication Gateway V2 from https://www.willmaster.com/software/gateway1/

It make the syndicated content search engine spider-friendly, use an SSI tag to insert the content into your web page. The SSI tag runs a CGI program that fetches and delivers the content.

The CGI Program

Here is the CGI program that will fetch the syndicated content and send it to your web page:

#!/usr/bin/perl
my $JavaScriptURL = 'http://example.com/file.js';
use strict;
use LWP::Simple;
my $content = get $JavaScriptURL;
$content =~ s/^\s*<!--//s;
$content =~ s!(?://)?\s*-->\s*$!!s;
my @content = split /[\r\n]+/,$content;
for(@content)
{
	unless(/^document/) { $_ = ''; next; }
	$_ =~ s/^document\.writeln\(\'//;
	$_ =~ s/'\)\;$//;
	$_ =~ s/' ?\+ ?'//g;
	$_ =~ s/\\'/'/g;
	$_ =~ s/\\\\/\\/g;
}
$content = join "\n",@content;
print "Content-type: text/html\n\n$content";
# end of script

Edit and save the above program using a plain text word processor like NotePad or TextWrangler.

  1. The first line must point to the location of Perl on your server.

  2. On the second line, replace the URL between the apostrophes with the URL of the syndicated content. This would be the URL found in the src="_________" attribute of the syndication <script...> tag. (To syndicate WillMaster Possibilities articles, use the /library/c/wmp.js URL.)

Upload the program to your server as ASCII/plain text, to a directory that can run CGI scripts. Give it 755 permissions.

It requires the Perl module LWP::Simple. If you are unsure whether or not your server has the module installed, ask your hosting company or use Master Pre-Installation Tester from https://www.willmaster.com/software/pit/

The SSI Tag

Here is the SSI tag that will run the CGI program:

<!--#exec cgi="/cgi-bin/programfile.cgi"-->

Replace "/cgi-bin/programfile.cgi" with the location and name of the CGI program on your server.

Use the SSI tag instead of the JavaScript syndication code.

On many servers, pages with SSI need to have file names with the .shtml extension. Your server may be different. Contact your hosting company if in doubt.

When you've installed the CGI program and use the SSI tag in lieu of the JavaScript syndication code, search engine spiders can index your syndicated content as if it was static content.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC