最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Speed up Auto-reload in Meteor.js - Stack Overflow

programmeradmin2浏览0评论

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.

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

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.

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.

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

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.

Share Improve this question edited Dec 31, 2013 at 19:22 Nyxynyx asked Dec 31, 2013 at 18:40 NyxynyxNyxynyx 63.7k163 gold badges506 silver badges856 bronze badges 2
  • Is it possible that the times it takes longer time to reload are when you have ran code that's crashed? – Peppe L-G Commented Dec 31, 2013 at 19:02
  • @PeppeL-G It also takes longer to reload when the code is working fine... I've estimated the range of browser reload times from 3 sec to 10 sec. – Nyxynyx Commented Dec 31, 2013 at 19:03
Add a ment  | 

3 Answers 3

Reset to default 6

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.

Some basics of it are:

  • 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.

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.

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.

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

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.

I revived an old project which had been running fine in 2014 with a fresh install of meteor, but found startup and restarts were really slow (over 30 seconds). (Possibly updating node or meteor had triggered this.)

I noticed that the project's .meteor/release contained [email protected]

I ran:

meteor update

in the project's root folder.

My release file now contains [email protected], and many of my packages were updated. Now restarts are significantly faster (about 10 seconds)!


By the way, I point MONGO_URL at the mongodb on my localhost, so meteor doesn't have to spin up a new mongodb when I start the app.

Seems to be solved with 1.3, but for now it is in beta.

meteor update --release [email protected]

From 6-10s to 1-2s.

发布评论

评论列表(0)

  1. 暂无评论