English 中文(简体)
How do I best prioritize HTTP requests on a web page?
原标题:

I need to prioritize the downloading of (in my case) images.

To do this I would prefer to use some kind of plugin (preferably for jQuery) that lets me do this without having to build my own downloadqueue mechanism.

Consider this scenario:

You have a web page. Your web page is able to show a given user three images. These images are only shown one at a time at the users request.

You would then ideally want to load the images from top to bottom until the user makes a selection. You would then want his selection to move up the queue and become next in line (with every selection he makes).

Of course in a page with only three images this isn t really a problem, but with more and more images it becomes important.

I am currently only using background-image to show images and would like to keep it that way.

Oh, and also, I would like a "spinner.gif" to show while an image is loading.

Any suggestions?

Thanks.

UPDATE I ended up making my own queueing system based on this: http://jqueryfordesigners.com/image-loading/

问题回答

Assuming the actual page will have a lot more than three images, take a look at this image Lazy Load Plugin . It s based around what is and what is not below the fold, works sequentially through the images, and can be configured to preload in X ones below the fold as you are scrolling. It allows for a placeholder image but might need some rewriting if you want it to expose background images rather than working on actual img tags.

Here s an example of loading on-demand or when scrolled into view. Though not directly answering your question but is fundamentally similar.

http://www.webresourcesdepot.com/dnspinger/

Try scrolling down and the page gets loaded with my content. Will work for images as well. The resource for this demo can be found at "Load Content While Scrolling With jQuery".





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签