preloading a webpage

I have a set of pages which load quite slow, thereafter super fast, I was wondering if there was a way to pre-load them at a login screen, if i do the following

page1.show
page2.show
page3.show
login.show

It will work ok but you see the pages loading, does anyone know if there a way to load them hidden?

Keep in mind that loaded pages can easily be accessed using browsers built-in developer tools. So, if you have a login system of sorts, don’t preload pages. At least not until after login :slight_smile:

Cover the contents with a rectangle that you hide when displaying the page, maybe :slight_smile:

Simply set the webpages as implicit instance, and they all get loaded at launch time. But as Albin said, not if you want to keep them secret.

I think you may also be playing with the browser cache when you display all of them. That is not preloading, this is the browser storing pages to display them faster afterward.

I hate to break it to you, but this “simply” isn’t true. WebPages are not actually sent to the browser until they are shown. All that the implicit instance does for you is keep a copy in memory for each session on the server so you can write:

WebPage2.Show

Instead of:

Dim w as new WebPage2 w.show

But they are still not sent to the browser until you call the Show method.

Note: Please check your assertions before answering…

[quote=286008:@Greg O’Lone]

Note: Please check your assertions before answering…[/quote]

Sorry, I inferred wrong. Next time I will wait until you say the law.

Is there no way to do what the OP asked, then ? It is possible for pictures, right ?

[quote=286018:@Michel Bujardet]Sorry, I inferred wrong. Next time I will wait until you say the law.

Is there no way to do what the OP asked, then ? It is possible for pictures, right ?[/quote]
Yes, pictures can be preloaded, but WebPages cannot. They are way more complicated in that’s they require JavaScript, HTML and CSS to actually come into being and I suspect that users preloading pages would have significant delays on the client side when deployed to the web. [quote=285859:@dave duke]I have a set of pages which load quite slow, thereafter super fast, [/quote]
I am guessing that you never actually close the pages once you’ve shown them. Be very careful with this. Pages that load slowly are usually the result of very complex designs which in turn mean more memory usage on the browser. Some browsers, mobile in particular, have hard memory limits and your app will cease to function if you go over that limit. You can check this on iOS by launching Safari on a Mac with an iPhone or iPad connected and use the developer tools to inspect the memory usage on the device. You’ll have to look up the memory limits though… the last time I looked, a single session was limited to 10MB on iOS, but that was a while ago, and I suspect that has been increased since then.

It doesn’t work that way. When a WebPage object is sent to the browser, it becomes part of the page that makes up your app. That is where most of the time resides though… in the actual delivery process. After the initial delivery, when you call Show, the browser is told to bring that page to the foreground, make it visible and make all other WebPages invisible. Then a command is sent back to the app on the server to fire the Shown event(s) where appropriate. The only way to properly clean up a WebPage is to call the Close method, but that also means that your app will have to deliver a new instance the next time you need it.

This is GREAT stuff Greg…

Regarding memory use and settings of images in a WebImageView, does setting the pic via URL or Picture use the same amount of memory?

+1.

[quote=286008:@Greg O’Lone]I hate to break it to you, but this “simply” isn’t true. WebPages are not actually sent to the browser until they are shown. All that the implicit instance does for you is keep a copy in memory for each session on the server so you can write:

WebPage2.Show

Instead of:

Dim w as new WebPage2 w.show

But they are still not sent to the browser until you call the Show method.

Note: Please check your assertions before answering…[/quote]

Please consider putting this in the Xojo Dev Center along with related information that will help us to make better design decisions for our Web apps.

I updated the Web App Optimization page with this info.

[quote=286163:@Hal Gumbert]This is GREAT stuff Greg…

Regarding memory use and settings of images in a WebImageView, does setting the pic via URL or Picture use the same amount of memory?[/quote]
Yes. Both in memory and on disk on the browser side…

On the server side it’s a different matter though. A WebImageView defined using a URL does not keep the file in memory on the server. Also if you use a WebFile or WebPicture you can have it point to a file on disk rather than load it into memory as well.

Thanks Paul!