PassionateDeveloper
PassionateDeveloper

Reputation: 15138

ASP.Net load pictures after background

I have an CSS Style and a page with 6 pics. When I open a normal page, all loads okay. When I open the page with the pics, the pics will load at the same time as the background and it needs a few seconds.

How to delay the picture-loading or set it a lower prio then the bg / design?

Upvotes: 2

Views: 345

Answers (2)

Dewfy
Dewfy

Reputation: 23634

Your css is embed to page with help of <link tag. On other hand it can have event 'onload'. So put it together and load picture after css has been loaded. To locate css-link from asp code use:

    ControlCollection headerControls = Page.Header.Controls;
    for (int i = headerControls.Count - 1; i >= 0; i--)
    {
        HtmlLink link = headerControls[i] as HtmlLink;
        if (link != null 
          && String.CompareOrdinal(link.Attributes["rel"], "stylesheet") == 0)
        {
            if (...) //add compare with your CSS name here
                link.Attributes["onclick"] = ...//add jscript to load image;
        }
    }

Upvotes: 0

rahul
rahul

Reputation: 187090

You can use this jQuery plugin for lazy loading images.

Lazy Load: Image lazy loader plugin for jQuery

Upvotes: 3

Related Questions