简体   繁体   English

对单个页面HTML5应用程序使用Mustache或任何模板引擎

[英]Using Mustache or any templating engine for a single page HTML5 app

I program using PhoneGap and learned that cross-platform apps really produces slow applications compared to native apps. 我使用PhoneGap进行编程,并了解到与本机应用程序相比,跨平台应用程序的生成速度确实很慢。 I learned from http://floatlearning.com/2011/05/how-well-does-phonegap-scale/ that javascript templating will significantly increase the speed of my mobile app. 我从http://floatlearning.com/2011/05/how-well-does-phonegap-scale/了解到javascript模板将大大提高我的移动应用程序的速度。

I develop single page apps. 我开发单页应用程序。 Magazine apps in particular. 特别是杂志应用。 Contains an overflow:hidden container for pages and page transition is held by left and right swipes (CSS3 Translates). 包含一个溢出:用于页面的隐藏容器,并且通过向左和向右滑动来保持页面转换(CSS3翻译)。 I would just like to ask how I can implement javascript templating (Mustache) to solve my performance problems with my magazine app. 我想问一下如何实现JavaScript模板(胡子)来解决我的杂志应用程序的性能问题。

Thank you and God Bless! 谢谢你,上帝保佑!

Here's a breakdown of performance when adding HTML to a page with Mustache vs a few other alternatives http://jsperf.com/adasdadsaddddddddddd 这是将HTML添加到带有Moustache的页面和其他一些替代方法时的性能细分,网址为http://jsperf.com/adasdadsaddddddddddd

From your last comment though, your biggest performance boost could come from image optimization. 不过,根据您的最新评论,最大的性能提升可能来自图像优化。 You could use any of the developer tools mentioned to see how many HTTP requests you're making for images, the size of them, and where your bottlenecks are. 您可以使用上述开发人员工具中的任何一个,以查看对图像发出的HTTP请求数,图像大小以及瓶颈所在。

Use tools like Smush.it to compress your current images. 使用Smush.it之类的工具来压缩当前图像。 Look to combine images to sprites where it makes sense. 设法将图像组合成有意义的子图形。 Explore CSS Data URIs . 探索CSS数据URI

After you've optimized your HTTP requests and images, then look to speed up rendering time of the DOM. 优化HTTP请求和图像后,请考虑加快DOM的渲染时间。 You may find that you could use something like Mustache to dynamically render "magazine pages" on swipe so you only have to layout the initial view. 您可能会发现,可以使用诸如Mustache之类的东西在滑动时动态呈现“杂志页面”,因此您只需要布局初始视图。

Analyze your app on page spped service and see Critical path report to check whats going on behind your website. 在页面加速服务上分析您的应用程序,然后查看“ 关键路径”报告以检查网站背后的情况。 you can also use console of chrome using performance.timing , it will show exact time loading statics of page. 您也可以使用performance.timing使用chrome控制台,它将显示加载页面静态信息的确切时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM