views:

91

answers:

1

I'm having some trouble to figure out how to make the "page load" architecture of a website.

The basic idea is, that I would use XSLT to present it but instead of doing it the classic way with the XSL tags I would do it with JavaScript. Each link link should therefore refer to a JavaScript function that would change the content and menus of the page.

The reason why I want to do it this way, is having the option of letting JavaScript dynamically show each page using the data provided in the first, initial XML file instead of making a "complete" server request for the specific page, which simply has too many downsides.

The basic problem of that is, that after having searched the web for a solution to access the "underlying" XML of the document with JavaScript, I only find solutions to access external XML files.

I could of course just "print" all the XML data into a JavaScript array fully declared in the document header, but I believe this would be a very, very nasty solution. And ugly, for that matter.

My questions therefore are:
Is it even possible to do what I'm thinking of?
Would it be SEO-friendly to have all the website pages' content loaded initially in the XML file?

My alternative would be to dynamically load the specific page's content using AJAX on demand. However, I find it difficult to find a way that would be the least SEO-friendly. I can't imagine that a search engine would execute any JavaScript.

I'm very sorry if this is unclear, but it's really freaking me out.
Thanks in advance.

A: 

Is it even possible to do what I'm thinking of?

Sure.

Would it be SEO-friendly to have all the website pages' content loaded initially in the XML file?

No, it would be total insanity.

I can't imagine that a search engine would execute any JavaScript.

Well, quite. It's also pretty bad for accessibility: non-JS browsers, or browsers with a slight difference in JS implementation (eg new reserved words) that causes your script to have an error and boom! no page. And unless you provide proper navigation through hash links, usability will be terrible too.

All-JavaScript in-page content creation can be useful for raw web applications (infamously, GMail), but for a content-driven site it would be largely disastrous. You'd essentially have to build up the same pages from the client side for JS browsers and the server side for all other agents, at which point you've lost the advantage of doing it all on the client.

Probably better to do it like SO: primarily HTML-based, but with client-side progressive enhancement to do useful tasks like checking the server for updates and printing the “this question has new answers” announce.

bobince
You certainly know your JavaScript ;-)I thought it was this way.The end point conclusion must be, from my point of view, that the smoothness in page requests by loading the specific pages' content just ain't SEO-compatible (and also lacks accessibility, but I don't agree with you on that).The only thing that bothers me then, is HOW I could access the underlying XML with JavaScript? Not to use it the way I mentioned before, I asure you.Thanks for the reply, by the way.
Sune Rasmussen
That's simple enough: a quick AJAX request to a server-side script that returns the exact portion of XML required for that particular functionality (either as XML, or, more usually these days as JSON, to cut down on the amount of annoying-to-write client-side XML-walking).
bobince
I'm not really sure what you mean by ‘smoothness’... users are used to navigation working like it does in browsers and modern browsers minimise the time spent ‘between pages’ to make navigation is quick as possible. You mess with expected behaviour like this at your peril! For example if you have a page that does a load of AJAX processing without the browser's usual visible indication that a navigation is happening, you may find your users sitting there repeatedly clicking the link and thinking it's not working.
bobince
I don't intend to get the XML/JSON for a functionality, like a live news feed, but to access the XML supplied to my XSLT "application" ;-) . It's how to get those data using JavaScript, and not the usual XSL, I don't know how to.Smoothness means, that instead of that the entire page reloads upon user interaction with a link, only those parts of the page that shall be changed will reload - using AJAX, for example. This could be some menus, which buttons' text shall change, and the content HTML which would propably all be inside the same DIV. Accompanied by some "Loading..."-graphic probably;)
Sune Rasmussen