加速Meteor.js中的自动重新加载 [英] Speed up Auto-reload in Meteor.js

查看:95
本文介绍了加速Meteor.js中的自动重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Meteor.js中保存带有新更改的文件后,服​​务器将重新启动,浏览器将重新加载窗口。

After saving a file with new changes in Meteor.js, the server will restart and the browser will window reload.

问题:有时保存文件后重新加载需要比平常更长的时间,这似乎是随机的。有没有办法更快地触发自动重新加载?

Question: Sometimes it takes longer than usual to reload after saving the file, and this appears to be random. Is there a way to trigger the auto-reload more quickly?

服务器似乎很快重启,但浏览器重新加载的速度要慢得多。

It appears that the server restart quickly, but the browser reload much more slowely.

Meteor服务器重新启动后,网页无响应30秒,网络选项卡显示 websocket 待处理......

After the Meteor server have restarted, the webpage becomes unresponsive for 30 sec and the Network tab shows websocket pending...

我在Mac OSX上的Node.js v0.10.22上使用Meteor 0.7.0.1和Meteorite 0.6.16,连接到远程MongoDB服务器。

I'm using Meteor 0.7.0.1 with Meteorite 0.6.16 on Node.js v0.10.22 on Mac OSX, connecting to a remote MongoDB server.

推荐答案

如果您的项目很大,自动重新加载需要时间。流星基本上必须重建javascript。有很多事情可以影响它所花费的时间。

The auto reload takes time if your project is big. Meteor basically has to rebuild the javascript up. There are a lot of things that can influence the time it takes.

它的一些基础是:


  • 项目规模越大&更多js文件/包需要的时间越长

  • 如果你已经禁用了websockets,服务器似乎需要更长时间才能重启

  • 如果你'重新使用 - production 作为标志,重建需要更长时间,但在浏览器中加载速度更快

  • 如果使用外部css / fonts通过cdn和东西有时需要更长的时间才能重新下载这些文件,这取决于你的连接。尝试检查chrome开发人员控制台中的网络选项卡,看看是否有任何特定文件需要一段时间并暂时在本地托管。

  • 如果您在出错后重新加载热码,可能会当meteor试图从错误中恢复时会有轻微的延迟。

  • The bigger the project & more js files/packages the longer it would take
  • If you've disabled websockets the server will appear to take longer to restart
  • If you're using --production as a flag it will take longer to rebuild but faster to load in the browser
  • If you use external css/fonts via cdn and stuff it can take a bit longer sometimes to redownload these files, it depends on your connection. Try checking your Network tab in the chrome developer console to see if there is any particular file taking a while and temporarily host it locally instead.
  • If you're hotcode reloading after an error there could be slight delays as meteor tries to recover from the error.

还有其他一些事情。如果您使用带有 - 发布标志的Meteor UI,则某些构建会出现内存泄漏,并且您的热代码重新加载的速度越慢越慢。

There are a couple of other things too. If you're using Meteor UI with the --release flag some builds have memory leaks and get slower and slower the more you hot code reload.

如果您正在开发Windows,那么热代码重新加载会遇到一些问题。 Windows上的Meteor是非官方的,你有时必须按ctrl + c并重新启动才能让它更快启动。

If you're developing on windows there are a few issues with hot code reloads. Meteor on windows is unofficial and you sometimes have to ctrl+c and restart it to get it to boot faster.

你可以做很多事情来加速它除了加强你的计算机或将在 Meteor.startup 中运行的东西移动到一个cron作业之外。每个热代码重新加载都会重做Meteor.startup中的任务。

There isn't alot that you can do to speed it up besides beefing up your computer up or moving stuff run in Meteor.startup into a cron job. Every hot code reload would redo the tasks in your Meteor.startup.

热门代码重新加载困扰我的那个是来自Google字体的字体,通过 @import css语句。有时谷歌不会很快提供字体,特别是当我不断重新加载它们时。我暂时禁用它们/在本地托管它们。我不在本地主持生产,因为不同的浏览器有时会在Windows上提供模糊字体。

The one that bothers me the most with hot code reloads is the fonts from Google fonts via the @import css statements. Sometimes google doesn't serve the fonts very quickly especially when I keep reloading them. I temporarily disable them/host them locally. I don't host locally in production because different browsers sometimes serve up fuzzy fonts on windows.

这篇关于加速Meteor.js中的自动重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆