ruby-on-rails – 性能问题:使用“link_to”还是“a”?

对于不需要太多控制器或选项的链接,使用html标签会更好吗?不必要地使用link_to rails标签会对性能产生任何影响吗?

谢谢.

解决方法

是.你可以在任何地方编写静态内容而不是动态内容,你会看到更好的性能.如果在特定情况下使用link_to使事情更易于编写和理解,那么使用它,但如果您自己认为没有必要,请节省cpu时间并自己编写标记.

这是专门讨论的,因为它与Rails助手in this article有关.根据文章

A number of helpers in Rails core will run rather slowly. In general,all helpers that take a URL hash will invoke the routing module to generate the shortest URL referencing the underlying controller action. This implies that several routes in the route file need to be examined,which is a costly process,most of the time… For pages displaying a large number of links,I have measured speed improvements up to 200% (given everything else has been optimized).

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...