ressio / lazy-load-xt

Lazy load XT is a jQuery plugin for images, videos and other media
http://ress.io/lazy-load-xt-jquery/
MIT License
1.36k stars 245 forks source link

Multiple widgets of the same tag? #23

Closed sirvon closed 9 years ago

sirvon commented 9 years ago

So what if I have 100 g+ buttons do I have to do this...

<div data-lazy-widget="gplus" />
<div id="gplus"><!-- same tag -->
<div data-lazy-widget="gplus1" />
<div id="gplus1"><!-- same tag -->
<div data-lazy-widget="gplus2" />
<div id="gplus2"><!-- same tag -->
...
<div data-lazy-widget="gplus100" />
<div id="gplus100"><!-- same tag -->
<!-- Google +1 Button -->
<div data-lazy-widget="gplus" class="g-plusone" data-annotation="inline" data-width="300"></div>
<div id="gplus"><!--
  <script type="text/javascript">
    (function() {
      var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
      po.src = 'https://apis.google.com/js/platform.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    })();
  </script>
--></div>

Or is there a more efficient DRY way?

dryabov commented 9 years ago

It's sufficient to load Google's platform.js once, so the code should be

<div data-lazy-widget="gplus" ... />
<div data-lazy-widget="gplus" ... />
...
<div data-lazy-widget="gplus" ... />
<div id="gplus"><!-- <script>...</script> --></div>