Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery-pjax vs history.js to load specific content when clicked

Tags:

html

jquery

ajax

I need to ajaxify my site, like loading a spinner or something for rendering specific content in a page when clicking a link.

I have found 2 good jQuery plugins.

  • https://github.com/defunkt/jquery-pjax
  • https://github.com/browserstate/history.js

What is their main difference? It seems they are doing the same job. Well, maybe one uses the ajax then returns the html (pjax) and one uses a so-called html5 push state or something.

Is there another way doing this? (simpler or with only jQuery) I think it's too overkill to use either of those plugins (but I'm not sure if there is a simpler way for doing this).

like image 632
Adam Ramadhan Avatar asked Jun 05 '11 18:06

Adam Ramadhan


1 Answers

author of History.js here.

  • History.js is extremely low-level and just focuses on providing a cross-browser compatible interface for the HTML5 History API
  • PJAX is high-level and utilises the HTML5 History API to provide a an interface for upgrading your website with AJAX using the two technologies.

So you can get PJAX to use History.js so that it supports cross browsers. There is actually a request about this here.

Though that doesn't mean History.js leaves you on your own either in regards to AJAX, it does provide you with a high-level sample for using History.js with AJAX here and you can find more info about how that was created here. Essentially that gist and PJAX do the same thing, but they have gone about them in different ways.

In regards to simpler, History.js is the most low-level basic shortest simple thing you can get which will ensure the HTML5 History API works in all browsers - that's it's aim, to be as low-level and compact as possible so other things can extend it the way they want - such as PJAX or that Gist.

like image 101
balupton Avatar answered Oct 14 '22 06:10

balupton