Content Management using AjaxInclude: Pros and Cons

Custom-assemble your Web page from multiple files

In my last post, I introduced the idea of assembling your Web site from multiple files using a JavaScript version of AjaxInclude. Please note that this idea is primarily intended for people using Microsoft Office Live Basics, or some other Web-hosting service that does not allow them to use true server-side includes on their Web sites. AjaxInclude scripts (available from Dynamic Drive) are intended to provide the minimal functionality (from a user’s perspective) to mimic a true server-side include script. The techniques discussed in this post, however, can be applied to any Web page. If you aren’t familiar with ASP, PHP, or PERL programming, you can use AjaxInclude to build similar functionality into any Web site.

Pros:

  • AjaxIncludes allows you to dynamically build your site using simple JavaScript codes. By adding a simple script to your page in a particular location (see example below), you can include the contents of another page within your site. This allows you to ensure that elements (such as navigation menus, images, and basic site structure) can be included on many pages within your site. Yet, if you want to update your site’s look, feel, or content, you only have to edit the included files, and the changes will be reflected on every page within your site.

    Sample AjaxInclude action (You must include the full AjaxInclude script {or a link to it} in the <HEAD> section of your site before calling this function):

    <script>
    ajaxinclude(“yourfile.htm”);
    </script>

  • AjaxIncludes can also be configured to dynamically display content. Suppose you had several different files that could be displayed on a specific page, depending on a specific parameter (perhaps, the day of the week). You could use JavaScript to determine the day of the week, and choose the appropriate content to display within your site based on that parameter. Alternatively, you could pass specific information through the URL of your site (yoursite.com/documents/pagename.htm?ShowContent=true). Again, you can use JavaScript to parse out the parameter(s) and determine the appropriate content to display on your site.

  • You can even use AjaxInclude to pass along information in the <HEAD> section of your document. In the <HEAD> section of your Web site, you can include a meta tag to point to your available RSS feeds:

    <link rel=”alternate” type=”application/rss+xml” title=”The Web for You (Blog)” href=”http://feeds.feedburner.com/TheWebForYou”>

    This tag helps Web browsers to auto-discover the RSS feeds for a site, especially since many of the feed sources are not located in the same domain (either the feed is produced and stored externally in a blog or using a service like FeedCraft, or the feed is re-directed through a service like FeedBurner).

    My own Web site, LockworldHerald.com (which is a testing-ground for building a better-than-average Web site using the free Microsoft Office Live Basics Web hosting service), currently has five RSS feeds available for subscription. Although this is far more than I actually need, or anyone would want to subscribe to, I have included the feeds to show off both how you can use Zoho Creator to easily provide subscriptions to your site content and how you can use AjaxIncludes to quickly and easily update your RSS list for every page on your site. As I add new feeds or change my list of feeds, I can update one file and ensure that every page in my site will start showing the updated information immediately. Even if you do not add or change your feeds frequently, it is probably a good idea to have these links passed on through an included file, rather than having to hard-code this information into every Web page on your site.

Cons:

  • The principal problem with using AjaxIncludes is that the included content is invisible to robots and spiders, such as those used by search engines to index the Web. This means that the included content of your page will not be indexed along with the other page contents. If you are using too many included files to actually deliver the content to your page, your site will not be properly indexed, and your Search Engine Optimization (SEO) will be ruined. To further complicate things, the included pages will be indexed separately by the search engines, and linked to in search results. This means that, rather than Web search results being directed to the page you want to display, visitors will be directed to incomplete portions of a page (the fragmentary included files) containing the search terms they specified.

  • AjaxIncludes can only include content from within your domain, which is a major drawback. Although there are many services which will allow you to store content on their sites, you can only dynamically include content from the same domain (yoursite.com, for example) in your page.

Summary:

Although AjaxIncludes can be used to build a very dynamic site, if they are overused, they will make your site invisible or worse to search engines. This is not a problem, however, if you are using AjaxIncludes the way they are best suited: For building page structure around your primary content.

That’s all for today. In my next post, I will be talking about using JSON feeds to add even more dynamic features to your Web site. If you want to get an idea of how this all works, you might want to read my September 10 post on Land of ZC, Use JSON to deliver Zoho Creator content to your Web site, to learn more about JSON and how to process the JSON feed for your site. You can also preview a sample application of what is possible using JSON feeds by viewing the new Recommended Resources section of my Web site. I use JSON feeds to dynamically display specific content from a single Web page. This is something I tried unsuccessfully to accomplish earlier in my e-commerce series. Thanks to JSON feeds, I have now significantly improved the technique.

One Reply to “Content Management using AjaxInclude: Pros and Cons”

  1. You are welcome to quote anything from this blog on your own blog. As a courtesy, I ask that you refer to me as the original author.

    It has been several years since I've paid any attention to this blog, so I don't have a Twitter account related to this blog or Web site. If I start posting again, I will probably set up a Twitter account to highlight any new posts.

    Thanks for your interest…

Leave a Reply

Your email address will not be published. Required fields are marked *