Jefe
Jefe

Reputation: 11

Django load parts of pages dynamically as they become available

I'm making a Django page that has a sidebar with some info that is loaded from external websites(e.g. bus arrival times).

I'm new to web development and I recognize this as a bottleneck. As it is, the page hangs for a fraction of a second as it loads the data from the other sites. It doesn't display anything until it gets this info because it runs python scripts to get the data before baking it into the html.

Ideally, it would display the majority of the page loaded directly off my web server and then have a little "loading" gif or something until it actually manages to grab the data before displaying that.

How can I achieve this? I presume javascript will be useful? How can I get it to integrate with my existing poller scripts?

Upvotes: 1

Views: 698

Answers (2)

Alper
Alper

Reputation: 3973

The easiest but not most beautiful way to integrate something like this would be with iframes. Just make iframes for the secondary stuff, and they will load themselves in due time. No javascript required.

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798764

You probably don't need up-to-the-second information, so have another process load the data into a cache, and have your website read it from the local cache.

Upvotes: 1

Related Questions