Meteor: pre-loading images

I built a meteorite app with a great background. Now the application starts, and the user can watch while the image is loading. It would be better for me to first download the desired background image, and if the download is completed, the application will appear. I tried to find some concepts for this, but I did not find a solution that can be used with a meteorite.

So, I thought about using the waitOn function for Iron-Router:

Router.route('/', { name: 'home', yieldRegions: { 'navigationBar': { to: 'navigation' }, 'contentPage': { to: 'content' } }, waitOn: function() { // Loading image, and if loaded, go further on... } }); 

Maybe someone has an idea how to do this ...

+5
source share
1 answer

Ok I’ve been thinking about this for some time. I could not find a sample code. But I started using appcache for meteor, and it works like a charm. Appcache is good for users who have already used the application at least once.

Here is the url: https://atmospherejs.com/meteor/appcache

It allows you to specify whether you want to cache a specific image (or any resource) or not.

To preload the image, preload, as in the preload mode, there are no packages for the meteor. I tried to preload the dream style old style image, and this view works, but it slows down the application a bit. I found this

https://github.com/farinspace/jquery.imgpreload

This seems like a better solution than using simple javascript.

0
source

Source: https://habr.com/ru/post/1232470/


All Articles