Ask DN: Show me your website!

over 7 years ago from Enakshi Roy, Compile Inc.

  • Stef KorsStef Kors, over 7 years ago

    Do you import your projects at the code section from github? I'm building my current portfolio where it also uses the github api to import. But because I'm a designer I have no idea what I could do to have quicker load times

    0 points
    • A. M. ­DouglasA. M. ­Douglas, over 7 years ago (edited over 7 years ago )

      Yes, I cheat and use JSONP. I pull the Github API endpoint down (async'd) and the callback fires a function declared prior, which receives the data, builds the repo elements and adds them to a container at once.

      <div id="github"></div> <script> function loadrepos(results){ "use strict"; if ( > 0 ) { for ( var i =; i-- ) { var repo_url =[i].homepage ?[i].homepage :[i].html_url, repo_name =[i].name, repo_desc =[i].description, repo_lang =[i].language, repo_container = document.getElementById("github"), el = document.createElement("div"), // each repo will be in one of these el_link = document.createElement("a"), // a link will wrap the title, description and language el_title = document.createElement("h4"), // title el_desc = document.createElement("p"), // description el_lang = document.createElement("p"); // language el_link.href = repo_url; el_link.title = repo_name; el_title.textContent = repo_name; // use textContent because it's faster than .innerHTML el_desc.textContent = repo_desc; el_lang.textContent = repo_lang; el_link.appendChild(el_title); el_link.appendChild(el_desc); el_link.appendChild(el_lang); el.appendChild(el_link); repo_container.appendChild(el); } } else { console.log('Github is down'); } } </script> <script async defer src=""></script>


      JSONP is technically more efficient and it's easier to work with!

      0 points