0

So I'm trying so so hard to find something for JavaScript or jQuery where I can use a lazy loading plugin or SOMETHING that goes a little like this:

if .post IS_NOT_IN_VIEW do{
dont_load();
 }else{
load();
}

I could've made that better xD. But hopefully you can understand what I mean by that. I just want something that'll STOP the loading of my content with a class of "post" but it'll load it when the user has the content in view.

Thank you if you can help... I had already posted a question like this but people just had problems with the post and I guess people just didn't even bother to look at it seeing it had 6 or 7 comments...

insanewolfhd
  • 81
  • 1
  • 11

1 Answers1

0

I think ajax addresses your question.

http://api.jquery.com/jquery.ajax/

You can load resources using this.

HTML:

$.ajax({
    method: "get",
    url: "some_url",
    dataType: "html"
})
.done(function( data ) {
    alert( "HTML content: " + html);
});

Or for json just change the dataType to json.

If you want to lazily load javascript:

How to dynamically insert a <script> tag via jQuery after page load?

Has some helpful answers.

Community
  • 1
  • 1
csga5000
  • 4,062
  • 4
  • 39
  • 52