Finally, figured out.
I had foolishly copied mup.js from the docs which had debug: true
, due to which meteor was building the app with --debug flag.
With one REALLY neat trick (clickbait lol), I have my fairly complex Meteor app with high quality video background (or image carousel on mobile) loading in a little over 200ms.
I donât know of any sites with similar content on the entirety of the internet loading that fast, let alone anything using Meteor.
I had my app loading time down to 1-2 seconds through a combination of on-demand external loading of non-critical javascript libraries and separating out âadminâ functions (and packages) to a separate admin-only Meteor instance, but to get sub-second load times I figured something out that I hadnât seen anyone doing yet.
I am not a web developer or programmer by trade so I hope Iâm not doing anything too bad or breaking something Iâm not aware of. My suspicion is I may be compromising SEO. I do of course have zero traffic for now so that probably helps
Will elaborate more on my main thread with a very overdue update.
Way to whet the appetite!
Sounds great! Waiting for the details.
From your source, it seems you are sending a pure html page (that matches to your home page), which gets loaded first while the js/css is being downloaded. Nifty!
Do let us know of further details.
Well since I got two responses already⌠spoiler alert
You inject HTML server-side depending on the inbound client route, ensuring the DIVs have classes that indicates it is special server-rendered HTML. In your real client-side template javascript .onRendered calls (yep Iâm using blaze!), execute $(â.ssrblahblayâ) remove commands and your client-side templates remove the server-rendered HTML as they are initialized.
It was kind of magical to see this work and I expected to see some flickering and weirdness. I was actually a little surprised that I hadnât seen this put together yet by anyone else.
And yes youâre technically sending down the same HTML twice, but the âcostâ of just some gzipped HTML is minimal.
I wanted to see if I could put some logic in the actual HTML I was sending to the client and found Arunodaâs SSR package which lets you pretty much copy/paste your client-side templates into being server side templates, even allowing you to replicate template helpers on the server. You can feed these templates variables which the helpers can then consume, which let you do things like render a server-side template for a possible user vs. non-user or pipe down language settings.
Arunodaâs inject-initial package also makes the whole injection thing pretty simple - at first I was using WebApp.connectHandlers.use which I learned about when I wanted to perform automatic geo-lookups for every new session (I now run geo-lookups in Meteor.onConnectionâŚ).
I also started doing the route/path detection with the Webapp connect handler function but decided to tidy things up and use my router â which is still good old iron-router. I have some routes specifically defined to show certain templates, and then I have a wildcard route which renders the navbar, a âloadingâ screen in the middle, and then a footer, for any routes I havenât fully defined yet.
Iâm also using fast-render, so youâre also getting rapidly rendered data-driven templates as soon as they get to the client for most of my routes (once the primary meteor client JS payload is loaded).
A good bit of work to get rid of the empty white loading screen typical of Meteor apps, but Iâm happy with the result. Itâs all a pretty tenable solution that is now easy to manage.
I still havenât described the little trick Iâm using to knock down the page load time to 200-300ms - more on that later, though I think itâs icing on the cake at this point and the things I mentioned above are sort of prerequisites. Being actual developers and able to inspect the web code you will figure it out anyway
Tell the world about it!
Hi! everyone. Im experiencing the same issue on a site we recently built. I wanted to see if anyone had any thoughts. The site link is below to check out.
Im thinking it has to do with the server downtime. if heroku shuts down the server it will take a bit to boot and then display the site but not totally sure just yet.
Id be appreciative of any feedback
It loaded almost instantly for me.
It must be server side then. When we load the page and havenât in a while it takes around 20 seconds.
Just tested it as well, took 20+ seconds for me. Youâre probably running it on a free heroku dyno as you mentioned it shutting down, if so just pay the 7$ and you wonât have any trouble.
Iâd like to throw Cloudinary in as an option to serve images http://cloudinary.com/ and this Meteor package https://github.com/Lepozepo/cloudinary .
Because send and retrieve is simple, you can also manipulate images upon request much like Drupal image styles (if youâre familiar with it). Very handy tool.
CC: @ashah888
Perfect thank you for the feedback !
Ok, since itâs now 2017 and I havenât posted my long overdue response to my initial post about nibbl.com, here you goâŚ
The thing I havenât seen done anywhere yet, that I came up with myself to get instantaneous page loads, faster than any other website using Meteor (or even meteor.com!) and quicker than any other website doing the full screen background video thing:
Defer the execution of your client-side Meteor JS payload to the browserâs onload event. BOOM.
I have a server-side web handler that manipulates Meteorâs returned JS payload to âreplaceâ it with a function that executes the payload once the browser onload event occurs.
I use iron-router to provide a server-side wildcard route (this.route(â/:query(.*)â) and Meteorhacks inject-initial to apply this to any request.
This would be quite useless and strange without SSR to deliver something to the browser before the onload event, but when you use SSR, the experience is pretty awesome.
Will try to work on posting up a more complete working example of this on Github when I can. Basically, in the route action() function, you execute this:
Ugly but it seems to work for now. Iâm a glorified scripter at best so take this all with a grain of salt
Thanks!, Would it make cense to use this if Iâm only doing client side rendering?
The technique is great (thanks to @benlavalley) , and it makes the websites âappearâ faster.
But I feel that it is difficult to code and maintain, because you need to create all those pages/templates again for SSR. I would personally advise you to just inject a simple loader on your webpage, so that people know that the data is coming, even before the app has been fully downloaded. That should be enough for small bootstrapped apps.
s7d, absolutely correct and that was what I considered trying to put together for an example.
Just sending down a simple "loadingâ page to start and use that for injection into the client, then tear it down with the method I mentioned above with one of your real templates executing $(â#someloadingtemplateâ).remove() in onCreated or onRendered. You could even have a âclick here to try againâ if youâre worried about your loading page somehow getting stuck.
I didnât find enough of a reason to leave Blaze yet for the web but plan to dive into React when biting the bullet to develop for iOS/Android â based on the page loading experiences with it (e.g. kadira) it looks like it does this kind of thing natively.
Oh, and this doesnât work properly in development mode â at least I havenât got it working yet. Youâll want to setup your route to detect if you are in dev or production mode and then only use this for production