javascriptnode.jsmeteormeteorite

Speed up Auto-reload in 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.

After the Meteor server have restarted, the webpage becomes 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.

enter image description here


Solution

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

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

    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.