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.

HTML5 validation fail with lazy load

See original GitHub issue

The lazy load feature uses the data-lazy attribute of the IMG tag. Unfortunately, this means that the src attribute is missing, which causes HTML5 validation to fail.

Error message from W3C validator: Element img is missing required attribute src.

Reference paragraph from HTML5 spec: The src attribute must be present, and must contain a valid non-empty URL potentially surrounded by spaces referencing a non-interactive, optionally animated, image resource that is neither paged nor scripted.

A possible solution, is to use a src attribute with a place-holder image (low res thumb, animated loader, small icon, etc). For example, another script which support lazy loading, uses the following IMG tag format:

<img src="icon.png" data-src="image250x.jpg" data-src-retina="image500x-retina.jpg">

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:11
  • Comments:7

github_iconTop GitHub Comments

9reactions
ghostcommented, Feb 22, 2015

I did not solve the problem, I only offered a possible solution. If we try to use the src attribute, then it breaks the lazy load engine. I also tried using a small place-holder image and it completely broke the slider height.

Why is HTML5 validation not relevant? I believe it is more relevant than before, even google gives higher marks in their search engine to sites with valid HTML5 code, over others.

6reactions
simeydotmecommented, Feb 22, 2015

This is not a bug, and you’ve solved your own problem 😄 HTML Validation is not relevant today 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lazy loading (data-src2) Jssor Slider doesn't validate against ...
To make an image lazy loading, the src attribute shouldn't be specified. The html5 validation will raise an error for image with no...
Read more >
Lazy loading & HTML Validation - WordPress.org
Hi,. When i try to validate html I get this error. Should I Ignore. Error: Element style not allowed as child of element...
Read more >
951697 - Error message of HTML5 input validation is not ...
Issue 951697: Error message of HTML5 input validation is not shown when using confirm ... The error message does not show in the...
Read more >
Extend HTML5 Form Validation With Custom Rules And Errors
Validate form fields on submit, blur and data change. Custom validation rules. Easy to add your own validators. Custom error messages. Useful ...
Read more >
Tips for authoring fast-loading HTML pages - MDN Web Docs
All eagerly loaded images are rendered before the document's load event is sent. Switching to lazy loading of images tells the browser to...
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