One page only javascript applications

前端 未结 8 821
野性不改
野性不改 2021-02-08 23:09

Have you experimented with single page web application, i.e. where the browser only \'GETs\' one page form the server, the rest being handled by client side javascript code (one

相关标签:
8条回答
  • 2021-02-08 23:48

    Maybe you should check SproutCore (Apple Used it for MobileMe) or Cappuccino, these are Javascript frameworks to make exactly that, designing desktop-like interfaces that only fetch responses from the server via JSON or XML.

    Using either for a blog won't be a good idea, but a well designed desktop-like blog admin area may be a joy to use.

    0 讨论(0)
  • 2021-02-08 23:54

    One pro is that you get the full presentation power of JavaScript as opposed to non-JavaScript web sites where the browser may flicker between pages and similar minor nuisances. You may notice lower bandwidth use as well as a result of only handling with the immediately important parts that need to be refreshed instead of getting a full web page back from the server.

    The major con behind this is the accessibility concern. Users without JavaScript (or those who choose to disable it) can't use your web site unless you do some serious server-side coding to determine what to respond with depending on whether the request was made using AJAX or not. Depending on what (server-side) web framework you use, this can be either easy or extremely tedious.

    It is not considered a good idea in general to have a web site which relies completely on the user having JavaScript.

    0 讨论(0)
  • 2021-02-08 23:54

    One major con, and a major complaint of websites that have taken AJAX perhaps a bit too far, is that you lose the ability to bookmark pages that are "deep" into the content of the site. When a user bookmarks the page they will always get the "front" page of the site, regardless of what content they were looking at when they made the bookmark.

    0 讨论(0)
  • 2021-02-08 23:56

    I was creating exactly these kind of pages as webapps for the iPhone. My method was to really put everything in one huge index.html file and to hide or show certain content. This showing and hiding i.e. the navigation of the page, I control in a special javascript file where the necessary functions for handling the display of the parts in the page are.

    Pro: Everything is loaded in the beginning and you don't need to request anything from the server anymore, e.g. "switching" content and performing actions is very fast.

    Con: First, everything has to load... that can take its time, if you have a lot of content that has to be shown immediately.

    Another issue is that in case when the connection goes down, the user will not really notice until he actually needs the server side. You can notice that in Gmail as well. (It sometimes can be a positive thing though).

    Hope it helps! greets

    0 讨论(0)
  • 2021-02-08 23:56

    The main reason to avoid it is that taken alone it's extremely search-unfriendly. That's fine for webapps like GMail that don't need to be publically searchable, but for your blogs and CMS-driven sites it would be a disaster.

    You could of course create the simple HTML version and then progressive-enhance it, but making it work nicely in both versions at once could be a bunch of work.

    0 讨论(0)
  • 2021-02-09 00:08

    I call these single page apps "long lived" apps.

    For "simpler applications" as you put it it's terrible. Things that work OOTB for browsers all of a sudden need special care and attention:

    • the back button
    • the refresh button
    • bookmarking/copying url

    Note I'm not saying you can't do these things with single-page apps, I'm saying you need to make the effort to build them into the app code. If you simply had different resources at different urls, these work with no additional developer effort.

    Now, for complex apps like gmail, google maps, the benefits there are:

    • user-perceived responsiveness of the application can increase
    • the usability of the application may go up (eg scrollbars don't jump to the top on the new page when clicking on what the user thought was a small action)
    • no white screen flicker during the HTTP request->response

    One concern with long-lived apps is memory leaks. Traditional sites that requests a new page for each user action have the added benefit that the browser discards the DOM and any unused objects to the degree that memory can be reclaimed. Newer browsers have different mechanisms for this, but lets take IE as an example. IE will require special care to clean up memory periodically during the lifetime of the long-lived app. This is made somewhat easier by libraries these days, but by no means is a triviality.

    As with a lot of things, a hybrid approach is great. It allows you to leverage JavaScript for lazy-loading specific content while separating parts of the app by page/url.

    0 讨论(0)
提交回复
热议问题