Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is a better way to lazy load content for users with javascript?
    primarykey
    data
    text
    <p>I have a page that has lots of images and other code that would work better if it is lazy loaded. </p> <p>I have been attempting to do this with the noscript tag but I just noticed that it is not working correctly in IE. It works in every other browser I tested (ff,opera,chrome,safari,etc) so I am a little frustrated. </p> <p>I am pretty sure at one point or another I actually had this working in IE because I have been using the technique for a little while and I test IE quite frequently... but it isn't working now and everything I google seems to suggest that it never worked.</p> <p>Here is a simple example to copy and paste that shows what I was attempting:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;lazy load with noscript&lt;/title&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;noscript&gt; &lt;div&gt; &lt;p&gt;other content here&lt;/p&gt; &lt;img src="http://www.google.com/images/logos/ps_logo.png" alt="lazy loading image test" /&gt; &lt;/div&gt; &lt;/noscript&gt; &lt;noscript&gt; &lt;div&gt; &lt;p&gt;other content here 2&lt;/p&gt; &lt;img src="http://www.google.com/images/logos/ps_logo2.png" alt="lazy loading image test 2" /&gt; &lt;/div&gt; &lt;/noscript&gt; &lt;script type="text/javascript"&gt; var html = $("noscript:first").text(); alert(html); $("body").append(html); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The html used for users with javascript and without javascript is the same. I just use jquery to tab the content to make it easier to view. Since the content is tabbed in javascript it needs to lazy load when a tab opens so it does not take ages to download initially when the page has sizable attachments.</p> <p>How can I achieve this without outputting the html more than once?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload