Search code examples
requirejscommonjs

Render github fork button


I want to render "reload" github buttons correctly, when i press on another button. I searched and i got this information, but I can't do it, i faced another error:

Uncaught Error: Module name "github-buttons" has not been loaded yet for context: _. Use require([]).

when i include http://requirejs.org/docs/release/2.2.0/minified/require.js


Solution

  • Node.JS is a server-side technology, not a browser technology. Thus, Node-specific calls, like require(), do not work in the browser.

    See browserify or webpack if you wish to serve browser-specific modules from Node.

    But you can use their steps in order to make this button...

    Usage:

    1. Place this tag where you want the button to render
    <a class="github-button" href="https://github.com/microsmsm" data-
    size="large" aria-label="Follow @microsmsm on GitHub">Follow 
    @microsmsm</a>
    
    1. Place this tag in your head or just before your close body tag
    <script async defer src="https://buttons.github.io/buttons.js"></script>
    

    Code Example:

    https://codepen.io/Microsmsm/pen/NvJaNm?editors=1100

    Reference:

    https://buttons.github.io/