1<!DOCTYPE html> 2<html> 3<head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width"> 6 <title>Reddit Keyword Trends</title> 7</head> 8<body> 9 <style> 10 body { 11 font-family:monospace; 12 } 13 * { 14 font-family:inherit; 15 } 16 </style> 17
17<script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.33.1/plotly-basic.min.js" async></script>
17 18 19 <h1>Reddit Keyword Frequencies Over Time</h1> 20 <p>This page will show you how often a particular word or phrase has been mentioned in each year since Reddit was created. The numbers are relative with respect to one another, so you can't interpret individual data points, but you can see how the frequency of a term changed over time. A higher number means that the <b>percentage</b> of comments mentioning that keyword was higher. But note that the y-axis does not correspond directly to the percentage of comments that mentioned the term. All credit for this simple project goes to the <a href="https://www.reddit.com/r/pushshift/" target="_blank">pushshift API</a>, which is where all the data comes from.</p> 21 <p>Please be patient while the data loads from pushshift's servers.</p> 22 <input type="text" id="searchInputEl" value="" onkeyup="if(event.which == 13) searchButtonEl.click()" style="width: 120px;"/><button id="searchButtonEl" onclick="window.location.href=`/keyword-trends/${searchInputEl.value.toLowerCase().replace(/\s+/g,'+')}?resolution=${resolutionEl.value}`" style="margin-right: 0.3rem;">load trends</button> 23 <select id="resolutionEl"> 24 <option value="year">yearly</option> 25 <option value="month">monthly (slow)</option> 26 </select> 27
27<script> 28 resolutionEl.value = "year"; 29 </script>
29 30 31 <br><br> 32 <div id="statusEl"></div> 33 <br> 34 <div id="chartEl"></div> 35 36 <div> 37 <a id="downloadCsvLink" style="display:none" target="_blank" download="data.csv"><button>Download CSV</button></a> 38 </div> 39 40
40<script> 41 function plotTimeseries(dataPoints) { 42 let data = [ 43 { x: dataPoints.map(p => p.date), y: dataPoints.map(p => p.value), type: "scatter" }, 44 ]; 45 let layout = { 46 margin: { l: 50, r: 10, b: 40, t: 20, pad: 5 }, 47 yaxis: { 48 rangemode: "tozero", 49 }, 50 }; 51 Plotly.newPlot("chartEl", data, layout, {displayModeBar: false}); 52 } 53 function dateToYYYYMMDDString(date) { 54 return `${date.getFullYear()}-${(date.getMonth()+1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`; 55 } 56 function status(msg) { 57 statusEl.innerHTML = msg; 58 } 59 (async function() { 60 let query = ""; 61 if(!query) return; 62 let yearlyTotalCounts = {"2007-01-01":1140421,"2008-01-01":3259821,"2009-01-01":8534802,"2010-01-01":21848365,"2011-01-01":53757072,"2012-01-01":111282275,"2013-01-01":169789140,"2014-01-01":225635033,"2015-01-01":292149375,"2016-01-01":352556742,"2017-01-01":422023689,"2018-01-01":511840703,"2019-01-01":670517888,"2020-01-01":846495136,"2021-01-01":900021331}; 63 let monthlyTotalCounts = {"2007-01-01":40956,"2007-02-01":47595,"2007-03-01":53521,"2007-04-01":59144,"2007-05-01":80640,"2007-06-01":84783,"2007-07-01":97581,"2007-08-01":105291,"2007-09-01":121599,"2007-10-01":130798,"2007-11-01":148966,"2007-12-01":169546,"2008-01-01":207456,"2008-02-01":203063,"2008-03-01":211882,"2008-04-01":215020,"2008-05-01":242961,"2008-06-01":264208,"2008-07-01":267336,"2008-08-01":271041,"2008-09-01":311186,"2008-10-01":353428,"2008-11-01":342785,"2008-12-01":369454,"2009-01-01":457545,"2009-02-01":417465,"2009-03-01":472818,"2009-04-01":487736,"2009-05-01":548012,"2009-06-01":583171,"2009-07-01":667985,"2009-08-01":780897,"2009-09-01":896989,"2009-10-01":1041497,"2009-11-01":1021369,"2009-12-01":1159313,"2010-01-01":1312168,"2010-02-01":1231182,"2010-03-01":1471813,"2010-04-01":1444667,"2010-05-01":1470643,"2010-06-01":1592825,"2010-07-01":1812005,"2010-08-01":1906306,"2010-09-01":2098944,"2010-10-01":2270749,"2010-11-01":2562241,"2010-12-01":2674817,"2011-01-01":2973361,"2011-02-01":2881536,"2011-03-01":3399304,"2011-04-01":3316366,"2011-05-01":3867961,"2011-06-01":4280399,"2011-07-01":4570613,"2011-08-01":5270253,"2011-09-01":5224231,"2011-10-01":5846631,"2011-11-01":5926745,"2011-12-01":6199649,"2012-01-01":7045010,"2012-02-01":6931223,"2012-03-01":7739273,"2012-04-01":8178023,"2012-05-01":8851503,"2012-06-01":9391176,"2012-07-01":10248228,"2012-08-01":10939120,"2012-09-01":9952348,"2012-10-01":10534435,"2012-11-01":10500515,"2012-12-01":10971373,"2013-01-01":12758222,"2013-02-01":11577624,"2013-03-01":13044525,"2013-04-01":13970182,"2013-05-01":14091299,"2013-06-01":13997696,"2013-07-01":14971609,"2013-08-01":14882724,"2013-09-01":13734723,"2013-10-01":15143213,"2013-11-01":15363917,"2013-12-01":16253354,"2014-01-01":17797853,"2014-02-01":16340450,"2014-03-01":18064368,"2014-04-01":17892604,"2014-05-01":18119079,"2014-06-01":17849629,"2014-07-01":19874851,"2014-08-01":19809111,"2014-09-01":19173571,"2014-10-01":20206706,"2014-11-01":19686897,"2014-12-01":20819810,"2015-01-01":23216784,"2015-02-01":21119101,"2015-03-01":23770218,"2015-04-01":23874700,"2015-05-01":23833725,"2015-06-01":23958227,"2015-07-01":25690574,"2015-08-01":25368739,"2015-09-01":24422566,"2015-10-01":26049956,"2015-11-01":25012358,"2015-12-01":25832300,"2016-01-01":27469607,"2016-02-01":26283578,"2016-03-01":28438242,"2016-04-01":28437528,"2016-05-01":28969144,"2016-06-01":29438639,"2016-07-01":29771321,"2016-08-01":31028910,"2016-09-01":29416805,"2016-10-01":30931993,"2016-11-01":30850866,"2016-12-01":31519964,"2017-01-01":34491499,"2017-02-01":30775061,"2017-03-01":34773932,"2017-04-01":33271749,"2017-05-01":34673688,"2017-06-01":34686485,"2017-07-01":35574219,"2017-08-01":36643274,"2017-09-01":34374448,"2017-10-01":37636799,"2017-11-01":37759719,"2017-12-01":37362650,"2018-01-01":39511916,"2018-02-01":37710775,"2018-03-01":41047070,"2018-04-01":41267471,"2018-05-01":42529705,"2018-06-01":41878691,"2018-07-01":44089488,"2018-08-01":44360229,"2018-09-01":42473804,"2018-10-01":45517007,"2018-11-01":44881886,"2018-12-01":46572472,"2019-01-01":53735846,"2019-02-01":49484409,"2019-03-01":54914679,"2019-04-01":53916479,"2019-05-01":55757556,"2019-06-01":54499992,"2019-07-01":59147384,"2019-08-01":59058512,"2019-09-01":56005253,"2019-10-01":58627423,"2019
63-11-01":56317452,"2019-12-01":59052668,"2020-01-01":62400321,"2020-02-01":60088422,"2020-03-01":66003749,"2020-04-01":70706913,"2020-05-01":76357929,"2020-06-01":75583710,"2020-07-01":77070526,"2020-08-01":58152350,"2020-09-01":67672718,"2020-10-01":72316304,"2020-11-01":67170400,"2020-12-01":72828340,"2021-01-01":67959417,"2021-02-01":53157723,"2021-03-01":41937739,"2021-04-01":66628473,"2021-05-01":70084087,"2021-06-01":67350942,"2021-07-01":75535460,"2021-08-01":87085847,"2021-09-01":84120455,"2021-10-01":85907692,"2021-11-01":86678362,"2021-12-01":89980499,"2022-01-01":98312040,"2022-02-01":86032935,"2022-03-01":94254973,"2022-04-01":90929765,"2022-05-01":91152828,"2022-06-01":87066096,"2022-07-01":96002038,"2022-08-01":97045992,"2022-09-01":93110845,"2022-10-01":93010357,"2022-11-01":89671888}; 64 let yearlyQueryCounts = {}; 65 let monthlyQueryCounts = {}; 66 67 let totalCounts = resolutionEl.value === "month" ? monthlyTotalCounts : yearlyTotalCounts; 68 let queryCounts = resolutionEl.value === "month" ? monthlyQueryCounts : yearlyQueryCounts; 69 70 if(Object.keys(yearlyQueryCounts).length == 0) { 71 let finishedLastMonth = false; 72 let resolution = resolutionEl.value; 73 for(let year = 2007; true; year++) { 74 75 if(resolution == "year") { 76 77 let startDate = new Date(year, 0, 1); 78 let endDate = new Date(year+1, 0, 1); 79 if(endDate.getTime() > new Date().getTime()) { 80 break; 81 } 82 status(`Collecting data for ${year}...`); 83 let queryCount = await fetch(`https://api.pushshift.io/reddit/comment/search/?q=%22${query}%22&limit=0&sort=desc&metadata=true&after=${Math.round(startDate.getTime()/1000)}&before=${Math.round(endDate.getTime()/1000)}`).then(r => r.json()).then(r => r.metadata.total_results); 84 yearlyQueryCounts[dateToYYYYMMDDString(startDate)] = queryCount; 85 86 } else if(resolution == "month") { 87 88 for(let month = 0; month <= 11; month++) { 89 let startDate = new Date(year, month, 1); 90 let endDate = month === 11 ? new Date(year+1, 0, 1) : new Date(year, month+1, 1); 91 if(endDate.getTime() > new Date().getTime()) { 92 finishedLastMonth = true; 93 break; 94 } 95 status(`Collecting data for ${year}-${(month+1).toString().padStart(2, "0")}-xx...`); 96 let queryCount = await fetch(`https://api.pushshift.io/reddit/comment/search/?q=%22${query}%22&limit=0&sort=desc&metadata=true&after=${Math.round(startDate.getTime()/1000)}&before=${Math.round(endDate.getTime()/1000)}`).then(r => r.json()).then(r => r.metadata.total_results); 97 monthlyQueryCounts[dateToYYYYMMDDString(startDate)] = queryCount; 98 99 if(window.Plotly) { 100 plotCounts(totalCounts, queryCounts); 101 } 102 } 103 104 if(finishedLastMonth) { 105 break; 106 } 107 108 } 109 if(window.Plotly) { 110 plotCounts(totalCounts, queryCounts); 111 } 112 } 113 } 114 115 status(`Waiting for graph software to download...`); 116 while(!window.Plotly) { 117 await new Promise(r => setTimeout(r, 100)); 118 } 119 120 plotCounts(totalCounts, queryCounts); 121 status(""); 122 123 let csvText = ""; 124 for(let [dateStr, totalCount] of Object.entries(totalCounts)) { 125 csvText += `${dateStr},${queryCounts[dateStr]/totalCount}\n`; 126 } 127 let blob = new Blob([csvText], {type: 'text/csv;charset=utf-8;'}); 128 downloadCsvLink.href = URL.createObjectURL(blob); 129 downloadCsvLink.style.display = "inline"; 130 131 function plotCounts(totalCounts, queryCounts) { 132 let dataPoints = []; 133 for(let [dateStr, totalCount] of Object.entries(totalCounts)) { 134 dataPoints.push({date:new Date(dateStr), value:queryCounts[dateStr] ? queryCounts[dateStr]/totalCount : null}); 135 } 136 plotTimeseries(dataPoints); 137 } 138 })(); 139 </script>
139 140
141<script type="module" src="https://static.cloudflareinsights.com/beacon.min.js/v31edd6df95cf4e85bb4c19e7a9bdbcba1788362987495" integrity="sha512-iIg7k2xntmwu6/uSb5tpc/hySgZc4eoL31yB29W6tJFo2akwjPWcEqnCEdJvGexCL0KEQwVYv5BlowfhVz26hg==" data-cf-beacon='{"version":"2024.11.0","token":"9eb3c17f8a1e4988b82afedc87b6bdca","r":1,"spa":2}' crossorigin="anonymous"></script>
141 142</body> 143</html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.