8

Ajax-only websites are laden with many problems. Search engine invisibility is merely a small problem. They are also unbookmarkable and unlinkable and they break the functionality of back- and forward-buttons without hacks. Fundamentally, they are not how the web is supposed to work. Even so, Ajax is indispensable to the user experience and Ajax-only applications are cleaner than hybrids in both code and logical structure, more powerful, and more extensible.

I can think of three solutions:

  • Cloaking. While cloaking typically bears the connotation of spamdexing a page with irrelevant keywords served only to a crawler, I mean serving a no-script user agent a stripped-down HTML file with exactly the same content that an Ajax client would load asynchronously (including the same hyperlinks), but without the fancy UI. It's intended for obsolete browsers as an alternative to progressive enhancement, not just for crawlability. Rationale: it doesn't waste no-script users' bandwidth with script tags or script-enabled users' bandwidth with noscript content that will be loaded anyways in JSON format. Drawback: it raises a false flag of search engine ranking manipulation, of which search engines are apparently hypervigilant. It is also difficult (at best) to recognize all potential user agents and differentiate correctly between those that execute scripts and those that don't.

  • Hash-bang fragment identifiers. Rationale: It doesn't appear deceitful to Google. Drawback: it is an absolutely backwards hack that violates the W3C's standard (by using illegal URLs) in favor of a trick invented by a third party. URLs are no longer Uniform Resource Locators; they are pointers to application entry points plus macros that Google and modern browsers luckily follow. This technique does nothing for true no-script browsers and it breaks any technology that follows the W3C more strictly.

  • Progressive enhancement. Rationale: this is championed as the way to use Ajax while adhering to the original vision of the web. It lets user agents with different capabilities act differently toward the same resource, and a hypervigilant client doesn't think it's being deceived. Drawback: it wastes bandwidth with script tags at best and redundant content in noscript tags at worst, defeating part of the purpose of Ajax.

If not for search engine hypervigilance, I would consider cloaking to be the best solution, although it would be much easier if clients would merely send an HTTP header (or lack thereof) indicating if they will execute scripts. Is it really that bad of a practice? Is there a way to prevent false flags of search engine manipulation? Or am I too paranoid of false flags in the first place?

3
  • I have always been of the opinion of "if it works, inst a bandwidth/browser hog, and isn't deceitful" then its ok. "Bad practice" is subjective as the web is still a very open platform, and even w3c very rarely state bluntly that something is bad practice. I sometimes ask myself if using a HTML table is bad practice as the CSS Nazis would have you think, but they work, perfectly well. Aug 3, 2012 at 7:17
  • Your example of Cloaking (send a basic page that works to no-script UAs) doesn't sound very different to the way I think of Progressive Enhancement (send a basic page that works to all UAs, and load/run enhancement scripts where possible). It wastes a miniscule amount of bandwidth with script tags that'll be completely ignored by no-script UAs. Additionally, how about using the history APIs (diveintohtml5.info/history.html) where possible, falling back to hashbangs where it isn't? Aug 21, 2012 at 16:32
  • User Experience? You do ajax and that's cool but if you do not let me right click on a link to successfully open in new tab, I will be annoyed and upset if all it does is cause some javascript error or a blank page. Second, hashbang/shebang links suck IMHO. What is wrong with push state. And third if we can't provide a proper URI with all the content then we are only being lazy in my opinion by not writing the fall back. Cloacking seems haphazard and a lazy solution to solve a problem. What about every other search engine bots like DuckDuckGo, Bing, Zandex, etc. Aug 25, 2012 at 0:02

0

Browse other questions tagged or ask your own question.