Closed peterblazejewicz closed 9 years ago
The main reason is raised by @jdaudier here:
https://github.com/marionettejs/marionettejs.com/issues/162
The 3rd party library is old and uses jQuery props deprecated from 1.9, so it's not future proof.
In addition - the website is using it purely for a single feature: stargazers.
stargazers
The use of this library can be replaced with JSONP call:
;(function($) { var url = 'https://api.github.com/repos/marionettejs/backbone.marionette?callback=?'; $.getJSON(url, function (result) { if(result.meta.status === 200) { var stargazers = result.data.stargazers_count || 'fetching'; var $span = $('<span></span>'); $span.appendTo('.github').text(stargazers + ' stargazers'); } }); })(jQuery);
that is:
diff --git a/bower.json b/bower.json index 47739e0..4e04499 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,6 @@ "jQuery.equalHeights": "mattbanks/jQuery.equalHeights#1.5.2", "google-code-prettify": "1.0.3", "jquery-unveil": "1.3.0", - "gh3": "1.0.3", "jquery": "2.1.3", "underscore": "1.6.0", "backbone": "1.1.2", diff --git a/gruntfile.js b/gruntfile.js index b538cd5..4189736 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -33,7 +33,6 @@ module.exports = function(grunt) { dist: { src: [ 'bower_components/jquery/dist/jquery.min.js', - 'bower_components/gh3/gh3.js', 'bower_components/jQuery.equalHeights/jquery.equalheights.min.js', 'bower_components/google-code-prettify/bin/prettify.min.js', 'bower_components/jquery-unveil/jquery.unveil.min.js', diff --git a/src/js/github.js b/src/js/github.js index d9c4e7e..31cafd7 100644 --- a/src/js/github.js +++ b/src/js/github.js @@ -1,15 +1,10 @@ -;(function(git, $) { - - var marionettejs = new git.User("marionettejs"); - var starGazers = new git.Repository("backbone.marionette", marionettejs); - - starGazers.fetch(function(err, res) { - if(err) { throw "No stars for you." } - - var count = document.querySelector('.github'); - var span = document.createElement('span'); - span.innerHTML = res.stargazers_count + " stargazers"; - count.appendChild(span); +;(function($) { + var url = 'https://api.github.com/repos/marionettejs/backbone.marionette?callback=?'; + $.getJSON(url, function (result) { + if(result.meta.status === 200) { + var stargazers = result.data.stargazers_count || 'fetching'; + var $span = $('<span></span>'); + $span.appendTo('.github').text(stargazers + ' stargazers'); + } }); - -})(Gh3, jQuery); +})(jQuery);
The JSONP unathorized access to GitHub api is subject of rate limits: https://developer.github.com/v3/#rate-limiting the same way as gh3.js asses I think.
Can we drop it?
Thanks!
:+1:
:+1: no need to open issues with the full diff, you can just open PR's :D
thanks for the great work @peterblazejewicz !
The main reason is raised by @jdaudier here:
https://github.com/marionettejs/marionettejs.com/issues/162
The 3rd party library is old and uses jQuery props deprecated from 1.9, so it's not future proof.
In addition - the website is using it purely for a single feature:
stargazers
.The use of this library can be replaced with JSONP call:
that is:
The JSONP unathorized access to GitHub api is subject of rate limits: https://developer.github.com/v3/#rate-limiting the same way as gh3.js asses I think.
Can we drop it?
Thanks!