Skip to content

Conversation

@RevisionTen
Copy link

Otherwise it won't work If the picture element has a fallback img inside of a script tag (the img in the script tag is selected and no new img element is appended to the picture element).

This fix is needed when dynamically adding picture elements with fallback img in a noscript tag.

…een loaded before

Otherwise it won't work If the picture element has a fallback img inside of a script tag (the img in the script tag is selected and no new img element is appended to the picture element).
@RevisionTen
Copy link
Author

Maybe this can also be fixed with a call to isLoaded instead.

@ApoorvSaxena
Copy link
Owner

@RevisionTen can you please share a codepen example where the existing implementation fails?

@RevisionTen
Copy link
Author

RevisionTen commented Oct 2, 2020

@ApoorvSaxena Sure, heres an example where it fails with an img inside a noscript:
https://jsfiddle.net/k4bzp596/

Heres the same code but without the noscript fallback img:
https://jsfiddle.net/7L9qzfwk/

I ran into this problem with a site where I load content containing lozad pictures via ajax for visitors that have javascript enabled (visitors without javascript are just opening a new page instead of dynamically loading the content).
A simple workaround was to just remove the noscript element before inserting the picture elements into the DOM (they don't need them anyways because they obviously have javascript enabled).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants