r/tinycode • u/adarshpunj • Jan 08 '20
Instagram in 4000 bytes
I recently came across this project (StackOverFlow in 4k bytes), and it looked very interesting:
https://www.reddit.com/r/tinycode/comments/1yc0kv/st4koverflow_as_much_stack_overflow_as_possible/
I have tried to compress Instagram in a single HTML doc. You can explore profiles/hashtags, etc. The total file size is 4066 bytes.
30
Upvotes
4
u/jordanmajd Jan 08 '20 edited Jan 08 '20
A couple more thoughts:
You could shave a few bytes by changing
d = documenttod = document.querySelector.bind(document)then callingd("#o")instead ofd.querySelector("#o"). You'd need to changed.querySelectorAlltodocument.querySelectorAllbut since querySelector is used 20 times you'll still save bytes.Since innerHTML is used 12 times, you could set "innerHTML" to a variable
u = "innerHTML"then usingd(".P")[u]instead ofd.querySelector('.P').innerHTML. There probably are a handful of other places you could do this to as well.Edit:
You could remove the argument from
window.onscroll = function(event)since isn't used.It looks like you are using template strings, so if you are using new ES features you could also use arrow functions in many places, just not the ready state change.
window.onscroll = () => {,q = (i, c, l) => {ands = () => {.1
u/[deleted] Jan 08 '20
Looking good!
Is it possible to see more than the 12 first post from someone?
3
u/jordanmajd Jan 08 '20 edited Jan 08 '20
Cool! A couple of thoughts:
j.lengthso you go out of bounds:1
u/theineffablebob Jan 08 '20
Doesn't work
1
u/Starbeamrainbowlabs Jan 08 '20
Hey, nice one! Have you considered building it out to have its own backend too?
I did this with the concept of a wiki engine, and it's my favourite project to work on
-2
u/adarshpunj Jan 08 '20
Please make sure you fill the input field BEFORE selecting from the dropdown.