Group: JavaScript Developers Task-Force/Reddit JavaScript Analysis

From LibrePlanet
Jump to: navigation, search

=== Essential Reddit functionality that doesn't work with LibreJS 6.0.5 enabled (as of 11/2014) There may be more, this is just from a preliminary look.


  • Login/out
  • Voting
  • Registering a new account is not possible, because the CAPTCHA is not displayed.

Changes that need to be made for reddit's essential functions to work with LibreJS enabledi

The majority of the scripts necessary for Reddit to function properly for the average user are, fortunately, free software. However, not all files are labelled as such. Additional efforts are also needed to ensure that LibreJS recognizes the distributed files as free.

Below, "source file" refers to the unminified source code in the Reddit repository.

Comments Page, et. al.i

reddit-init.en.js

  • The outer try/catch is added by r2/r2/lib/js.py:425
    • Its license is irrelevant because the JavaScript is trivial
  • lib/json2.js
    • It is in the public domain
  • lib/underscore-1.4.4.js
    • Expat
  • lib/store.js
    • Expat
  • lib/jed.js
    • Some modifications made by reddit, as noted within the file
    • WTFPL
    • *Zak verified that the license is indeed free.*
  • base.js
    • The source file contains no license
    • FIX: Add license to source file
  • preload.js
    • The source file contains no license
    • FIX:Add license to source file
  • logging.js
    • The source file contains no license
    • FIX: Add license to source file
  • uibase.js
    • The source file contains no license
    • FIX: Add license to source file
  • i18n.js
    • The source file contains no license
    • FIX: Add license to source file
  • utils.js
    • The source file contains no license
    • FIX: Add license to source file
  • analytics.js
    • The source file contains no license
    • FIX: Add license to source file
  • jquery.reddit.js
    • The source file contains no license
    • FIX: Add license to source file
  • reddit.js
    • The source file contains no license
    • FIX: Add license to source file
  • spotlight.js
    • The source file contains no license
    • FIX: Add license to source file
  • adzerk

reddit.en.js

Similar to above; ordered concatenation and subsequent minification:

  • templates.js
    • The source file contains no license
    • FIX: Add license to source file
  • ui.js
    • The source file contains no license
    • FIX: Add license to source file
  • login.js
    • The source file contains no license
    • FIX: Add license to source file
  • flair.js
    • The source file contains no license
    • FIX: Add license to source file
  • interestbar.js
    • The source file contains no license
    • FIX: Add license to source file
  • visited.js
    • The source file contains no license
    • FIX: Add license to source file
  • wiki.js
    • The source file contains no license
    • FIX: Add license to source file
  • apps.js
    • The source file contains no license
    • FIX: Add license to source file
  • gold.js
    • The source file contains no license
    • FIX: Add license to source file
  • multi.js
    • The source file contains no license
    • FIX: Add license to source file
  • recommender.js
    • The source file contains no license
    • FIX: Add license to source file
  • JSON generated from r2/r2/lib/permissions.py
    • License irrelevant; it is data. The Python file is under the Common Public Attribution License
  • Unknown r.config.cursed; not in the repository!
    • The JavaScript is small and it looks like it's just intended to be a fun toy
      • It randomly positions elements that you mouse over, it looks like
      • But regardless, it's non-free JS
    • FIX: Add to the repository with license information
    • Ends with a trivial line that does not appear to be in the repository
      • Simply adds an i18n message; code is 104 chars and would look no different if not minified
      • FIX: Add to the repository with license information


Changes that would be good to make, but which are not necessary for the site's essential functions to work with LibreJS on

This is not comprehensive, but would be an excellent start.

Privacy Policy

Preferencesi

  • jquery.js
    • Used on https://ssl.reddit.com/prefs/
    • Already includes this header (just need to make LibreJS-compatible): /*! jQuery v1.7.2 jquery.com | jquery.org/license */
    • FIX: Make aforementioned header LibreJS-compatible

ajax.googleapis.com/**/*.js

  • We obviously cannot add license headers to these files
    • FIX: Use a separate page to describe licenses (Web Labels)

Blog

The blog is a particular concern---it uses a great deal of JavaScript, but seems to work fine without JavaScript enabled.

s.ytimg.com/yts/jsbin/*.js

  • www-embed-player.js
    • Proprietary YouTube JavaScript
    • Used for embedded video player
    • FIX: Perhaps they could use an HTML5 player with free codecs instead, since YouTube serves up HML5-compatible content for many videos

www.youtube.com/embed/*

  • Used on blog.reddit.com
    • FIX: They can provide us with the source code, or commit it to the repository
  • Various embed stuff for iframes; includes above JS
  • Contains non-free JavaScript used as configuration for above YouTube include
    • That said, it's primarily data; it may be trivial
  • Loads http://www.google.com/js/bg/J3oN4k55bATX3riG5_bT7XUBXDr4fHU0iSqBW5OwyBU.js
    • Some Google anti-spam thing
    • Proprietary JS
    • FIX: Same as above---use HTML5 video player with free codecs, if possible

https://accounts.google.com/o/oauth2/postmessageRelay?parent=http%3A%2F%2Fwww.blogger.com#rpctoken=378573301&forcesecure=1

  • Loads ssl.gstatic.com/accounts/o/1618667077-postmessagerelay.js
    • Proprietary JS
    • FIX: Remove.

http://www.google-analytics.com/ga.js

  • Proprietary JS
  • FIX: Remove.

www.blogger.com/static/v1

  • jsbin/3672639782-lbx.js
    • 582kB of proprietary JS
  • widgets/3561504294-widgets.js
    • 85kB more proprietary JS
  • Loads over half a dozen more smaller scripts from apis.google.com on top of that
  • FIX: Remove.

https://apis.google.com/js/plusone.js

  • The notorious Google+ +1 button!
    • Can track users
  • FIX: Remove; they can always share the link on their own

reddit.com

  • static/button.js
    • Combined, minified file
    • lib/jquery.cookie.js
      • Dual Expat/GPL
  • jquery.reddit.js
    • The source file contains no license
    • FIX: Add license to source file
    • blogbutton.js
      • The source file contains no license
      • FIX: Add license to source file

About

redditstatic.com

  • about.js; concatenated, minified:
  • (minified blob)
    • Not in the repository!
    • Might be part of Modernizr; looks to modify the Date object for consistency
    • No license and might be proprietary
    • FIX: Add to repository with license information
  • (minified blobs)
    • Not in the repository!
    • Some trivial hooks and stuff, on top of what's listed below (which is non-trivial and extensive)
  • The following Backbone views/models:
    • SlideShowView
      • AboutSlideshowView
    • TimelineEvent
    • TimelineEventView
    • TimelineView
      • AboutTimelineView
    • GridView
      • PeopleGridView
    • AboutSlideshowView
    • TeamRouter
    • DropdownView
    • TeamMember
    • SortableCollection
    • PersonDetailsPopup
    • PersonView
    • Postcard
    • PostcardCollection
    • PostcardRouter
    • PostcardOverlayView
      • PostcardInfoView
      • PostcardRedditView
      • PostcardCloseView
    • PostcardZoomView
    • PostcardView
    • PostcardGridView
  • No license and is therefore proprietary
  • FIX: Add to repository with license information

General

Quick License Addition

This simple shell/sed script can be used to add the license header to all source files in one go, assuming that such a header is contained within the file license_header:

$ sed -i '
  1{
    r ./license_header
    h;d
  }
  2{H;g}' r2/r2/public/static/js/*.js