Unable to load image

Do YOU know why the emoji picker freezes rDrama?

If you look at the code, it's because for whatever reason, the emoji loader code creates an array that maps tags to emojis... but for some reason, they decided to implement this by storing an array of tags and then binary searching that array for EVERY TAG that must be updated -- consider that each of the 5,000 some emojis have multiple tags! Plus, they create multiple DOM elements for each emoji! This code has O(m * n * log(n)) complexity, where m is the average number of tags per emoji and n is the number of emojis. This code could very simply be sped up by using a hashmap (which is builtin with JS's Map) or by doing this work on the server and saving the result, so you would send back a JSON file like

{
    "tags": {
        "marsey": ["marseylove", "marseyfemboy", ...],
        "othertag": ["emoji1", "emoji2"....]
   }
}
81
Jump in the discussion.

No email address required.

Okay but then you would have to update it for each emoji that is added which is totally unfeasible.

It loads on my old phone with no problem so you must be using a computer from the stone age if you think something is wrong with how it works currently.

Jump in the discussion.

No email address required.

Please don't comment on coding-related stuff if you can't code. It's totally feasible and in fact more computationally efficient to do it that way.

Jump in the discussion.

No email address required.

Please don't comment on coding-related stuff if you can't code.

:marseysurejan: :marseylaugh:

It's totally feasible and in fact more computationally efficient to do it that way.

No it isn't. It's perfectly fine how it works now.

Jump in the discussion.

No email address required.

>No it isn't.

Yes it is. I could explain it to you, but I doubt you would understand.

Jump in the discussion.

No email address required.

Yes it is. I could explain it to you, but I doubt you would understand.

Yes please explain how your personal problem requires unnecessary feature bloat to the detriment of every other user on this site.

Jump in the discussion.

No email address required.

What do you mean "personal problem"? Look how long this freezes after I start typing out an emoji

Jump in the discussion.

No email address required.

You're looking in the wrong spot. If you did a little more digging and testing, you would realize that uses of the inline emoji picker are only slow on the first use on a page.

You are correct that that is not as efficient as it could be, but the main reason it's slow on the first load is that it has to make a request to get the emoji list on each page load. Since there's no caching headers on it and it's dynamic, the browser redoes the request every time.

@Aevvan could you please add a cache header or even better an etag to the emoji list route. That should be the easiest way to fix the issue. The alternative, but probably much more work and less effective, is to save the list plus timestamp to localstorage or indexeddb and then check it daily on the coient

Jump in the discussion.

No email address required.

You are wrong. Fetching doesn't cause the page to freeze. It's because it's iterating through all emojis, doing the expensive tag calculation, and generating DOM elements for each. JS blocks the main thread, fetch does not.

Jump in the discussion.

No email address required.

But we can fix that by using blocking xhr :marseyfluffy:

Jump in the discussion.

No email address required.

I see what you're referring to now. We're both correct, though I never paid much attention to the blocking scripts and was only thinking about the network request. I suppose I underestimated its impact. On my machine the emoji json is ~450ms (50/50 for response/download) on the network side and blocking scripts is ~750ms. Still, both should be improved.

Jump in the discussion.

No email address required.

Yes personal problem because this never happens that long for me you just have a slow device.

Also you didn't explain how yet.

Jump in the discussion.

No email address required.

Reported by:
  • Lappland : Too stupid? But you can't explain something?

Exiled for 1 day.

Reason: Too stupid for /h/slackernews, go back to the main feed.

Jump in the discussion.

No email address required.

You don't want to explain because you cannot. You can't justify your ideas by laying out the facts in a rational way that can challenge what I said so you have to resort to having a sperg out.

Jump in the discussion.

No email address required.

More comments

The emote picker is slow for me too but I just bite the pillow about it.

Jump in the discussion.

No email address required.

Your'e really trying to become my enemy now, huh?

Jump in the discussion.

No email address required.

My love has room for contempt :marseyhearts: :marseyp!athetic2:

Jump in the discussion.

No email address required.

I didn't even read your original comment but now I went back and did. You already are my enemy besides being my friend because you're one of my biggest downvoters.

Go back through and explain your reasoning for each downvote you've given.

Jump in the discussion.

No email address required.

More comments
Link copied to clipboard
Action successful!
Error, please refresh the page and try again.