question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why isn't my simple code working?

See original GitHub issue

Below is a very basic example, and images load before i scroll onto them. What possibly am i doing wrong?

<!DOCTYPE html>
<html>
<head>
	<title>Lazy loading</title>
	                
</head>
<body>

<img class="lazyload" data-src="img1.jpg">

<img class="lazyload" data-src="img2.jpg">

<img class="lazyload" data-src="img3.jpg">

<img class="lazyload" data-src="img4.jpg">

<img class="lazyload" data-src="img5.jpg">

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lazyload@2.0.0-beta.1/lazyload.js"></script>
<script>
	lazyload();
</script>
</body>
</html>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Sep 12, 2017

this is the right syntax replace your <script> whith this code

<script> $("img.lazyload").lazyload({ effect : "fadeIn" }); </script>
0reactions
prateekvarmacommented, Sep 30, 2017

@bhansa Sorry for the late reply. It works now! I’m not sure what was i missing. here’s the fiddle - https://jsfiddle.net/prtkvarma/2tm3q7ha/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why isn't my simple code working? - Beginning Java
So I'm just wondering if someone could explain why my simple code isn't working.
Read more >
24+ Reasons Code Doesn't Work & How To Fix It - WP SITES
Discover the most common reasons your CSS or PHP doesn't work or breaks your site when it really does work properly.
Read more >
Why won't my code work!? - The Beginner's Guide to Fixing ...
Why won't my code work!? - The Beginner's Guide to Fixing JavaScript Bugs · Step 1: Check your files · Step 2: Open...
Read more >
Coding problems? Learn what to do when you're stuck
Even the best programmers get stuck sometimes. Here are some tips to help you get unstuck and learn from your mistakes.
Read more >
Why does my code never work? Is it a problem in my abilities ...
Answer: Most of the time my code does not work when I finish writing it. Actually I am amazed when 100 or so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found