One thing that bothers a lot of creators(including me) is, well, what if I post at the wrong time? What if I post and my post will get barely any traction and all my effort will go to waste?
But not to worry, I found a way to get an idea of when the best posting times are for different tags on dev.to!
The solution
I made a NodeJS script that:
- Scrapes the dates on which the top 50 posts of the last year for different tags have been posted on.
- Converts the dates to weekdays.
- Prints the first, second and third best days of the week to post on for a tag.
The code
Here's the code that does the magic:
index.js
const puppeteer = require('puppeteer');
async function bestdays() {
const browser = await puppeteer.launch({});
days = []
var page = await browser.newPage();
const args = process.argv.slice(2)
await page.goto('https://dev.to/t/'+args[0]+'/top/year');
for(x = 0;x < 50;x++){
try{
let date1 = await page.$eval("#substories > div:nth-child("+x+") > div > div.crayons-story__top > div > div:nth-child(2) > a > time", element=> element.getAttribute("datetime"))
const d = new Date(date1);
let day = d.getDay();
days.push(day)
}
catch{}
}
function getAllIndexes(arr, val) {
var indexes = [], i = -1;
while ((i = arr.indexOf(val, i+1)) != -1){
indexes.push(i);
}
return indexes;
}
function max(input) {
if (toString.call(input) !== "[object Array]")
return false;
return Math.max.apply(null, input);
}
var indexes1 = getAllIndexes(days, 0);
var indexes2 = getAllIndexes(days, 1);
var indexes3 = getAllIndexes(days, 2);
var indexes4 = getAllIndexes(days, 3);
var indexes5 = getAllIndexes(days, 4);
var indexes6 = getAllIndexes(days, 5);
var indexes7 = getAllIndexes(days, 6);
dm = [indexes1.length, indexes2.length, indexes3.length, indexes4.length, indexes5.length, indexes6.length, indexes7.length]
dm2 = []
weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
console.log("\n")
console.log("Best day: "+weekdays[dm.indexOf(max(dm))]+" with "+max(dm)+" top posts from last year")
for (j = 0; j < dm.length;j++){
if (j != dm.indexOf(max(dm))){
dm2.push(dm[j])
}
else{
dm2[j] = 0
}
}
console.log("Second best day: "+weekdays[dm2.indexOf(max(dm2))]+" with "+max(dm2)+" top posts from last year")
dm3 = []
for (j = 0; j < dm2.length;j++){
if (j != dm2.indexOf(max(dm2))){
dm3.push(dm2[j])
}
else{
dm3[j] = 0
}
}
console.log("Third best day: "+weekdays[dm3.indexOf(max(dm3))]+" with "+max(dm3)+" top posts from last year")
console.log("\n")
await page.close()
await browser.close()
}
bestdays();
Make sure to have NodeJS and Puppeteer installed before running the script, then run the code by entering node index.js
and the tag you want to get the best posting times for (without the #) in your terminal.
For example: node index.js webdev
.
Once you've ran your script you should see that it outputs something similar to the following.
Best posting days for 20 of the most popular tags
For people who don't want to setup the script themselves, here are the best posting days for the top 20 most popular tags on dev.to:
Javascript
Best day: Wednesday with 10 top posts from last year
Second best day: Thursday with 10 top posts from last year
Third best day: Saturday with 10 top posts from last year
it's a tie
Webdev
Best day: Wednesday with 14 top posts from last year
Second best day: Thursday with 11 top posts from last year
Third best day: Friday with 7 top posts from last year
Tutorial
Best day: Wednesday with 9 top posts from last year
Second best day: Saturday with 9 top posts from last year
Third best day: Thursday with 8 top posts from last year
React
Best day: Wednesday with 12 top posts from last year
Second best day: Saturday with 10 top posts from last year
Third best day: Thursday with 9 top posts from last year
Python
Best day: Tuesday with 12 top posts from last year
Second best day: Sunday with 12 top posts from last year
Third best day: Monday with 8 top posts from last year
Productivity
Best day: Wednesday with 12 top posts from last year
Second best day: Monday with 11 top posts from last year
Third best day: Friday with 10 top posts from last year
CSS
Best day: Wednesday with 14 top posts from last year
Second best day: Tuesday with 8 top posts from last year
Third best day: Thursday with 8 top posts from last year
Devops
Best day: Wednesday with 12 top posts from last year
Second best day: Friday with 9 top posts from last year
Third best day: Saturday with 7 top posts from last year
Discuss
Best day: Friday with 11 top posts from last year
Second best day: Monday with 10 top posts from last year
Third best day: Wednesday with 7 top posts from last year
Career
Best day: Tuesday with 11 top posts from last year
Second best day: Monday with 9 top posts from last year
Third best day: Wednesday with 8 top posts from last year
Opensource
Best day: Wednesday with 11 top posts from last year
Second best day: Monday with 9 top posts from last year
Third best day: Friday with 8 top posts from last year
Node
Best day: Sunday with 14 top posts from last year
Second best day: Tuesday with 8 top posts from last year
Third best day: Thursday with 8 top posts from last year
HTML
Best day: Wednesday with 11 top posts from last year
Second best day: Tuesday with 9 top posts from last year
Third best day: Thursday with 9 top posts from last year
Codenewbie
Best day: Wednesday with 12 top posts from last year
Second best day: Monday with 9 top posts from last year
Third best day: Tuesday with 8 top posts from last year
AWS
Best day: Monday with 12 top posts from last year
Second best day: Wednesday with 10 top posts from last year
Third best day: Tuesday with 9 top posts from last year
Typescript
Best day: Tuesday with 10 top posts from last year
Second best day: Monday with 8 top posts from last year
Third best day: Saturday with 8 top posts from last year
Android
Best day: Tuesday with 10 top posts from last year
Second best day: Wednesday with 10 top posts from last year
Third best day: Friday with 7 top posts from last year
Java
Best day: Sunday with 14 top posts from last year
Second best day: Wednesday with 8 top posts from last year
Third best day: Monday with 7 top posts from last year
Github
Best day: Monday with 14 top posts from last year
Second best day: Tuesday with 9 top posts from last year
Third best day: Friday with 6 top posts from last year
Blockchain
Best day: Monday with 9 top posts from last year
Second best day: Friday with 9 top posts from last year
Third best day: Saturday with 9 top posts from last year
another tie
That's it for this article, hope it was helpful! Follow for more programming stuff.
Top comments (36)
Or you could...if you were really silly...just:
I would imagine the results would look something like this if anyone was silly enough to attempt to do it (third table):
inhu.co/dev_to/analyse/timeofday.php
But nobody would be silly enough to do that now would they? 😉
Being serious for a second, I didn't think to break it down by tag...might have to look into that if I ever get around to finishing that project as that is a great idea!
Great post, as you can probably tell I find stuff like this really interesting! ❤🦄
I am about to ask you on another article discussion (that you share the tables link) how did you get the final result 🤣
Thanks!
Could you please share which time zone do you use in this table? Thanks!
It is GMT, hope that helps!
This is a better approach I think, the person didn't knew about the API
Their approach was far more efficient though, I just brute forced it!
The DEV API is not well publicised either to be fair, so it is easy to miss.
Love it!
What on earth do these numbers and colors mean? Did I miss the legend?
No it is for personal use so it is not user friendly!, I just happened to share it in case it was useful for someone. The numbers are reactions / article released at a given time as an average. The colours are just a heat map, dark green is best (and yes the colours are awful!) 🤣
While a very impressive effort, and I love it, I should point out that there is a risk here of the classic confusion between correlation and causation. This confounds forecasting all the time and is a central conversation among forecasters I think.
Why? Well this is a forecasting effort, that is the first observation. Essentially we're hoping to predict that if I post my JavasScript article on Wednesday my chances of reaching people, gaining views and reactions, rises. While not explicitly stated, it's implicitly the goal.
One of the main tools forecasters have is history. But all history can show us quickly and easily is correlated measures. In this case we see a correlation between Wednesday posts and appearing in the top 50.
But for this to form a substantial forecast we need to assume or demonstrated or hypothesise if you will a causative relationship. Is it the case that posting on Wednesday raises the likelihood of that. A true forecasting effort pursues some evidence as to that hypothesis.
One hypothesis is that the editors compiling those lists attend to the job on Thursday as a routine ;-). Confirmation would require a word from DEV editors.
I'm pretty sure the top posts lists are compiled automatically by number of reactions and/or reads.
I guess it might also be that there are a couple of really big creators in a tag like Javascript that just routinely post on a Wednesday and get the attention of their followers no matter what and become top posts.
Still, I doubt that this is the case because from what I've seen, the top 50 posts from a tag are dominated by at least twenty different creators.
As for evidence, of corse, if you make a crappy post but post it on a Wednesday, you still won't get good results. But considering that you've made a proper post for a tag, taking into account that the biggest portion of the top 50 posts in your tag have been posted on a Wednesday, wouldn't that, considering the diversity of the posts and creators in the top 50 list, increase your post's likelihood of performing better than it would have if you had posted say on a Monday?
wow! most common days are Wednesday and Thursday ✌🏼
That's why I posted on a Thursday ;) 👍
awesome 😄 and I can see this as a top post 🤞🏻
It's good. You could get data through api tho:
https://dev.to/search/feed_content?per_page=50&page=1&tag=javascript&sort_by=public_reactions_count&sort_direction=desc&tag_names%5B%5D=javascript&approved=&class_name=Article&published_at%5Bgte%5D=2021-03-03T16%3A05%3A19Z
I've never heard of this API. How did you find it?
Oh I just checked network tab :)
Dev.to have their own api. Just search devto API on google. You can do ton of stuff with it. Great post btw
Love the analysis and great work building the app to gather the data.
Thanks ;)
Awesome! Thanks! :D
Great idea for a project! Also, great work on the project! 👊
Thanks👌
Now I will post only on Wednesday.
Thanks man!
Awesome work creating a solution that outputs an insight!
Interesting. What about the best time of day?
@code_jedi, I am interested in the best time of the day too 🤓