0
  1. URLs shall be without hashbang
  2. It shall fall back for older Browsers which don't support the History API
  3. Using Angular or Ember

Question: Is there a need to use the history.js? If yes, read on.

On teamwork.com or soundcloud or other modern websites there is a mechanism to have links loading just a part of the website and at the same time, the URL changes (there is no hashbang). I want to implement this as well and also want to support older browsers and read that history.js can do this. Here is a related question to this where I found that this uses the History Api.

At the same time I want to uses Angular or Ember. I know they have their own routing and there is for example a tutorial to remove the # here.

I read that the different browsers handle the history api differently and that the history.js is a way how to tackle this issue.

So is there a way how to combine those front-end frameworks with that api? I'd start somewhere in the routing but get stuck thinking about what to do...

A new implementation should have cross-browser compatibility including handling older browsers. On one hand I want to have a front end framework to separate front from the backend, not sure about which one to use, yet. On the other hand I like how i.e. teamwork.com handle links that they only load a part of a page (including an animation) when you click on it. At the same time the URL changes and if you type a URL directly the page is loaded correctly. It seems that they do it with jQuery.. not quite sure.

Anyone knows how to use both, routing and the history.js?

Community
  • 1
  • 1
hogan
  • 1,145
  • 12
  • 26
  • What problem are you trying to solve or what are you wanting to do with this? – charlietfl Oct 24 '15 at 10:51
  • Updated the question. – hogan Oct 24 '15 at 21:44
  • angular has several routers available already. As for older browsers current angular framework support is IE9 and higher – charlietfl Oct 24 '15 at 22:20
  • Ember has an option to use browser history API. – sheriffderek Oct 24 '15 at 22:28
  • The hash should not be seen and older Browsers supported. As I see from other posts, ember and angular support the first but dont fall back automatically on older browsers. The history.js does provide that so how can someone combine this? – hogan Oct 25 '15 at 21:41
  • I think you read something wrong somewhere.... angular definitely falls back on browsers that don't support the history api. https://docs.angularjs.org/guide/$location. Aside from that, you don't appear to be asking a tangible question, but asking for advice for a project that isn't even in development yet. – Claies Oct 26 '15 at 22:26
  • @Claies: I tried to describe this somehow but it seems that I wasnt clear enough. Do I understand you right that there is no need to use history.js at all then? (I read it for ember, not angular - you are right - and skipped explaining enough in the comment: http://stackoverflow.com/questions/15056877/does-ember-routing-fall-back-to-using-a-hash-if-browser-doesnt-support-the-hist?rq=1) – hogan Oct 27 '15 at 08:52
  • I don't develop actively in ember.js, but with how fast these frameworks are developed and modified, I wouldn't take a post made in 2013 as absolute fact for the state of the framework in 2015. As for angular, you definitely would not need a library like history.js when using it. However, if you are targeting browsers that don't support the historyAPI correctly, then there are likely *other* limited support aspects to most newer SPA frameworks. In general, support for browsers like IE 8 has all but been abandoned. – Claies Oct 27 '15 at 10:27

1 Answers1

0

I would just use AngularJS with UI Router. It combines routing with history.js like features. It has a HTML5 mode which you can enable which will allow pages to update via AJAX without the use of a hash #.

It should automatically cope with older browsers and change the URL format accordingly.

Chris
  • 24,827
  • 43
  • 179
  • 317
  • I just updated the question, do I understand you right, that history.js is already implemented into the UI Router? And I dont need to worry about this at all? – hogan Oct 27 '15 at 08:59
  • Angular UI Router will maintain your browser history and will essentially do the job of history.js. It will do this automatically though so you don't have to manually update the history state. It should be, once implemented, far easier – Chris Oct 27 '15 at 10:13