Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embeds with <script src> aren't lazy lazy loaded #19

Open
dimadin opened this issue Jan 3, 2016 · 0 comments
Open

Embeds with <script src> aren't lazy lazy loaded #19

dimadin opened this issue Jan 3, 2016 · 0 comments
Labels
enhancement topic:iframe Issues related to the lazy loading of iframes

Comments

@dimadin
Copy link

dimadin commented Jan 3, 2016

Some embed providers use <iframe> for loading of their content, but other use plain HTML or iframe followed by <script src>. Most notable example is Twitter, but there are others like Tumblr, Vine, Instagram...

Here is a Twitter example:

<blockquote class="twitter-tweet" width="500"><p lang="en" dir="ltr">Some content...</p>&mdash; Milan Dinić (@dinicmilan) <a href="https://twitter.com/dinicmilan/status/682154806358720512">December 30, 2015</a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

This means that their JavaScript file is loaded and <iframe> created while loading page and lazy loading is not working for them. In my commit dimadin/bj-lazy-load@5bf81af, I showed how this can be done for Twitter, but this is not practical because all sources must be manually defined and they can change.

What can be done is to do some regex to find script source, then replace that <script> tag with placeholder image, while JavaScript can stay the same or similar as in my commit. The only question is what to do if script has more attributes.

Other option is to put some trigger in your JavaScript file so that I don't need to edit that file after updates.

@jan-san jan-san added enhancement topic:iframe Issues related to the lazy loading of iframes labels Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement topic:iframe Issues related to the lazy loading of iframes
Projects
None yet
Development

No branches or pull requests

2 participants