为客户端MV*框架提供no-js回退

时间:2022-05-15 15:45:47

I just recently got introduced to MV* frameworks and have taken a chance to try out Ember.js with the TodoMVC app tutorial they have on their site.

我最近刚刚介绍了MV*框架,并尝试了烬。他们在自己的网站上有TodoMVC应用教程。

I was considering using Ember for one of my upcoming projects (a Ruby on Rails CRUD app, similar to Twitter in some of the functionality), but I'm still a bit confused and before I take a final decision I would love it if somebody could clear the following concerns:

我曾考虑过在即将到来的一个项目中使用Ember(一个Ruby on Rails CRUD应用程序,在某些功能上类似于Twitter),但我还是有点困惑,在我做出最后决定之前,我希望有人能解决以下问题:

  1. Is it a good idea to use such an advanced framework as Ember for a medium-sized multi-page CRUD app? Will it improve development time and maintenance compared to an interactivity layer built with jQuery's DOM manipulation and AJAX capabilities? Or is using Ember (and the like) only good when developing complex single-page apps (e.g.: Grooveshark)?

    对于一个中型的多页面CRUD应用来说,使用像Ember这样的高级框架是个好主意吗?与使用jQuery的DOM操作和AJAX功能构建的交互性层相比,它能改进开发时间和维护吗?或者,在开发复杂的单页应用程序(例如:Grooveshark)时,使用Ember(以及类似的东西)仅仅是好的吗?

  2. Considering the app will be developed using Rails, and assuming Ember will be used, is it going to be possible to offer a fallback with basic functionality for browsers with JavaScript disabled and/or for search engine crawlers? Will it require code duplication or other dirty tricks? Do you know of any technique that can be used to achieve it?

    考虑到该应用程序将使用Rails开发,假设使用了Ember,那么是否有可能为禁用JavaScript和/或搜索引擎爬虫的浏览器提供基本功能的备份?它需要代码复制或其他肮脏的伎俩吗?你知道有什么技术可以用来实现它吗?

  3. Will it be possible to adapt the website for mobile browsing (using only CSS) with valid results, or will the overhead imposed by running Ember on the phone make it hard for the device to render the website in a way that keeps it responsive?

    是否有可能调整网站的移动浏览(仅使用CSS)的有效结果,或运行烬在手机上的开销,使设备很难以一种保持其响应的方式呈现网站?

3 个解决方案

#1


3  

We're in the middle of a pretty big Ember project right now, so here are my thoughts on your questions.

我们现在正处于一个非常重要的烬项目中,所以这是我对你的问题的看法。

  1. We've found Ember to be really productive for creating rich UIs for our single page app, but I don't know that it's going to be that much more helpful if you're creating an app designed for traditional multi-page (viewing pages, submitting forms, etc) layout.

    我们发现Ember对于为我们的单页面应用程序创建丰富的ui非常有用,但是我不知道如果你要创建一个为传统的多页面(查看页面、提交表单等)布局设计的应用程序会有多大的帮助。

  2. I think this is the clincher - Ember is completely JS-based, so if you need to support browsers without JS, you'd basically have to write a parallel application. If this is a hard requirement for your app, I think Ember (or any MV* JS framework) would be out of the question

    我认为这是决定性的一点——Ember是完全基于jms的,所以如果您需要支持没有JS的浏览器,那么您基本上需要编写一个并行应用程序。如果这是您的应用程序的严格要求,我认为Ember(或任何MV* JS框架)将是不可能的

  3. We've had very few performance issues on mobile - our site is fully responsive and renders on everything from Blackberries to the latest Chrome on desktop with good performance.

    我们在移动设备上遇到的性能问题很少——我们的站点响应速度非常快,从黑莓到最新的桌面Chrome,我们的站点都有出色的表现。

#2


0  

@Scott Rankin, has addressed most of the concerns with going with the Pure Ember approach. I'll add one quick way to make this decision.

@Scott Rankin已经解决了使用纯烬方法的大多数问题。我将添加一个快速的方法来做这个决定。

Go with Ember/MVVM if the application is behind a login. Then you don't have to consider search engines, as the content is generally private and not supposed to be indexed.

如果应用程序是在登录后,请使用Ember/MVVM。然后,您不必考虑搜索引擎,因为内容通常是私有的,不应该被编入索引。

For SEO you have to build atleast part of your content such that it is indexable. A good example of this is the Discourse application. They use Ember but also send down some generated html along with the app html slugs, so that search engines can index them. You can read about their approach here.

对于SEO,你必须至少建立你的内容的一部分,这样它是可索引的。一个很好的例子就是语篇应用。他们使用烬,但也发送一些生成的html连同应用的html鼻涕虫,以便搜索引擎可以索引他们。你可以在这里读到他们的方法。

#3


0  

We have a different approach which can be seen as a fall back: We pre-render a static version of each page in the application (daily scheduled task). This static version is stored on the server as HTML file. Whenever we sniff as spider/ robot user agent, we deliver that version.

我们有一种不同的方法可以看作是倒退:我们预先呈现应用程序中每个页面的静态版本(每日计划任务)。这个静态版本作为HTML文件存储在服务器上。无论何时我们嗅探作为蜘蛛/机器人用户代理,我们都会交付那个版本。

#1


3  

We're in the middle of a pretty big Ember project right now, so here are my thoughts on your questions.

我们现在正处于一个非常重要的烬项目中,所以这是我对你的问题的看法。

  1. We've found Ember to be really productive for creating rich UIs for our single page app, but I don't know that it's going to be that much more helpful if you're creating an app designed for traditional multi-page (viewing pages, submitting forms, etc) layout.

    我们发现Ember对于为我们的单页面应用程序创建丰富的ui非常有用,但是我不知道如果你要创建一个为传统的多页面(查看页面、提交表单等)布局设计的应用程序会有多大的帮助。

  2. I think this is the clincher - Ember is completely JS-based, so if you need to support browsers without JS, you'd basically have to write a parallel application. If this is a hard requirement for your app, I think Ember (or any MV* JS framework) would be out of the question

    我认为这是决定性的一点——Ember是完全基于jms的,所以如果您需要支持没有JS的浏览器,那么您基本上需要编写一个并行应用程序。如果这是您的应用程序的严格要求,我认为Ember(或任何MV* JS框架)将是不可能的

  3. We've had very few performance issues on mobile - our site is fully responsive and renders on everything from Blackberries to the latest Chrome on desktop with good performance.

    我们在移动设备上遇到的性能问题很少——我们的站点响应速度非常快,从黑莓到最新的桌面Chrome,我们的站点都有出色的表现。

#2


0  

@Scott Rankin, has addressed most of the concerns with going with the Pure Ember approach. I'll add one quick way to make this decision.

@Scott Rankin已经解决了使用纯烬方法的大多数问题。我将添加一个快速的方法来做这个决定。

Go with Ember/MVVM if the application is behind a login. Then you don't have to consider search engines, as the content is generally private and not supposed to be indexed.

如果应用程序是在登录后,请使用Ember/MVVM。然后,您不必考虑搜索引擎,因为内容通常是私有的,不应该被编入索引。

For SEO you have to build atleast part of your content such that it is indexable. A good example of this is the Discourse application. They use Ember but also send down some generated html along with the app html slugs, so that search engines can index them. You can read about their approach here.

对于SEO,你必须至少建立你的内容的一部分,这样它是可索引的。一个很好的例子就是语篇应用。他们使用烬,但也发送一些生成的html连同应用的html鼻涕虫,以便搜索引擎可以索引他们。你可以在这里读到他们的方法。

#3


0  

We have a different approach which can be seen as a fall back: We pre-render a static version of each page in the application (daily scheduled task). This static version is stored on the server as HTML file. Whenever we sniff as spider/ robot user agent, we deliver that version.

我们有一种不同的方法可以看作是倒退:我们预先呈现应用程序中每个页面的静态版本(每日计划任务)。这个静态版本作为HTML文件存储在服务器上。无论何时我们嗅探作为蜘蛛/机器人用户代理,我们都会交付那个版本。