Hacker News new | ask | show | jobs
by emeidi 4226 days ago
Sounds like a solution looking for a problem:

"Create an AJAX request to the location (eg.: /about.html). Change the URL in the browser with the history API (this way, the back and forward buttons still work in the browser). Show a loading animation that the content is now being loaded. When the content is loaded, parse it to extract the contents of #main (you can help yourself there by adding markers in your HTML) and replace the content of your current #main section with the one you just loaded. Make sure that you handle all the links in your new #main content so they will act the same and fire off any BrowserScript required for the page that just loaded."

Aside of usability issues (what if the user has JavaScript disabled?), I don't really get how search engine spiders will be able to index the web site.

2 comments

I didn't quite get this either. It seems that a developer would also have to do extra parsing on top to determine which links are external and which are internal. The only impression I got is that he just created a more convoluted way of linking between documents.
Users without JavaScript (sorry, BrowserScript!) will load links as normal.

All the endpoints serve static html. I have no idea what the point in ajaxing it is (so you can stick in a pointless animation I guess). However it would degrade nicely, and search engines would be unaffected

Loading the content resources with AJAX allow you to preserve the current UI state. Depending on your website and your needs this step might be completely unnecessary.

It becomes necessary when you have elements that you want to persist on your page. That might be an audio player or the state of a menu that you want to avoid painting.

It's just about a better UX for your users.