10

While developing my meme website I think my newest js-file is oddly satisfying to look at ❤️

Comments
  • 2
    Link it when it's done 😁
  • 2
    @arwTheDev the website is under development but the built in features fully functional - and it's theoretical public
  • 4
    Why do you use a variable to store a value before you return it? Just return the value!
  • 2
    @greg- I needed it before I created the syncRequest function. It's from a forgotten past of myself 😥
  • 3
    The calls for 'var array' and var data' are repeated in each function. I would refactor and turn that into it's own function, looks like it just needs two parameters. I think you'll find it even prettier that way.
  • 4
    Lots of unnecessary/redundant stuff... Not very satisfying IMO
  • 2
    I dunno. Writing code is like maintaining your own house while fixing up other people's houses for a living. You just don't get time to fix everything you want to.

    Perfect code takes time. And if its a once off project it's okay as it is.
  • 0
    @hexc the code is still unfinished ^^ (after that picture I worked about 2 hours on that follow system) it's just beautiful if you know my other JS classes ^^
  • 2
    Please don't use synchronous requests. They'll be deprecated in the future.
  • 0
    @PrivateGER I know but I need to figure out how to make sth like a callback function.. :/ dunno how jet. Because my website loads posts one after another async calls will return mixed posts
  • 0
    @PrivateGER the problem is: I need to load posts in synchronized order, but I don't know how to do it with async requests.. :/ I read about promises and all that stuff but I don't think I understand it. I have my post loader sit in an for loop and if I use async calls the posts come in at random positions
  • 1
    @SteffTek Try to look into await or using .then().
  • 0
    @PrivateGER Then I have a problem with my for loop... But I have another idea I will try later ^^
  • 1
    Just load all yours posts in a single request, the requests hold return an array of post!
  • 1
    @greg- That is an extremely bad idea that will suck up tons of bandwidth and defeat the purpose of asynchronous loading.
  • 1
    @PrivateGER what's the worst, loading all the posts in a single async request or loading each post in a different sync request?
  • 1
    @PrivateGER @greg- did it asynchronous now... Did googled for about ever and find a solution suitable. Got everything covered asynchronous now ^^ still not pretty but getting there
  • 0
    @PrivateGER I want to mention that the website is currently hosted on my local server with Cloud-Flare protection. So Jeah, I try to keep my bandwidth use to a minimum ^^
  • 1
    @greg- Different requests are better. If your only requests fails, you lost.
    Also, multiple allow for fetching many things at the same time.
  • 1
    Couldn't all this be solved with a simple Promise.all ? This basically lets you wait till all promises finish before running the .than code
  • 0
    @hexc Didnt worked for me, tried it, nothing happend :/ but I got it to work with my solution above :)
Add Comment