mozillascience / PaperBadger

Issuing badges to credit authors for their work on academic papers
https://badges.mozillascience.org/
Mozilla Public License 2.0
95 stars 45 forks source link

Update example to load the widget non-blocking #128

Closed abbycabs closed 9 years ago

abbycabs commented 9 years ago
<script type="text/javascript">
   var script = document.createElement("script");
   script.type = "text/javascript";
   script.src = "https://badges.mozillascience.org/widgets/paper-badger-widget.js";
   document.body.appendChild(script);
</script>

Replace:

<script src="https://badges.mozillascience.org/widgets/paper-badger-widget.js"></script>

This way, if badges.mozillascience.org goes down, it won't take your site with it!

abbycabs commented 9 years ago

Hey @aperala, are you interested in updating the README section you wrote with non-blocking code?

Let me know :)

aperala commented 9 years ago

will do!

Alicole commented 9 years ago

@acabunoc That snippet didn't work for us, however this one did, which we used before: document.write(decodeURIComponent("%3Cscript src='https://badges.mozillascience.org/widgets/paper-badger-widget.js' type='text/javascript'%3E%3C/script%3E"));

aperala commented 9 years ago

@acabunoc Should I use the snippet that @Alicole has provided instead of what's above? I'm having the same result with that snippet-- the error message is showBadges() not defined.

abbycabs commented 9 years ago

that sounds like the file hasn't finished loading before you call showBadges -- please test these out and find a good solution to add to the readme :)

Thank you so much for helping us here, @aperala!

On Fri, Sep 25, 2015 at 5:53 PM, aperala notifications@github.com wrote:

@acabunoc https://github.com/acabunoc Should I use the snippet that @Alicole https://github.com/Alicole has provided instead of what's above? I'm having the same result with that snippet-- the error message is showBadges() not defined.

— Reply to this email directly or view it on GitHub https://github.com/mozillascience/PaperBadger/issues/128#issuecomment-143371138 .

aperala commented 9 years ago

the snippet @Alicole worked for me, so I've replaced with that. Just submitted a PR.