rafaelgomesxyz / esgst

An extension that enhances SteamGifts / SteamTrades.
MIT License
147 stars 23 forks source link

Optimize the order that the features are loaded #526

Closed rafaelgomesxyz closed 6 years ago

rafaelgomesxyz commented 6 years ago

Features that are not dependent on another feature should be the first ones to load and features that load content asynchronously should be the last ones to load.

gizellos commented 6 years ago

Where exactly I can see this?

rafaelgomesxyz commented 6 years ago

What do you mean?

gizellos commented 6 years ago

If there is a place where I could see this improvement in action. I would like to know if the difference is noticeable just for an eye, or it is a matter just of a few milliseconds.

rafaelgomesxyz commented 6 years ago

Well, it's too early to talk about that, I haven't even started working on the issue yet.

gizellos commented 6 years ago

LOL, sorry, I thought this was a commit.

rafaelgomesxyz commented 6 years ago

Hehe :P

Eiion commented 6 years ago

Features that are not dependent on another feature [...] should be the last ones to load.

Actually these should be the ones loaded first since they don't have to wait for data from the steam servers (or such). Right now they (e.g. the comment box on top - as we've talked about) is loaded as one of the last things.

rafaelgomesxyz commented 6 years ago

@Eiion Just a typo.

By the way, the comment box on top has already been moved to the top of the queue in v7.16.0. Have you noticed anything?

Eiion commented 6 years ago

Yep, I've noticed a change but it's still not "first". First the original page gets loaded, the your changes take effect. Not sure if that can be further improved from your side or not. Also, the button changing from "Submit Comment" to "[paper plane] Submit" makes it lag for a second - but that was there before as well. Not sure why to change it in the first place when it adds very noticably time to the page load.

rafaelgomesxyz commented 6 years ago

That could be improved on my side by making the script run on document_start instead of document_end, which is basically before any other scripts are loaded, but I'm not sure if that could have side effects on some features. I'll test it out.

The button changing is Discussion Edit Detector's doing, but it can be optimized as well, since DED is currently at the bottom of the queue.

rafaelgomesxyz commented 6 years ago

Latest dev version should be faster.

Eiion commented 6 years ago

Looking at GA pages I don't notice a difference. The page still gets loaded in first and only after that the comment box jumps on top. Also, the comment formatting helper buttons only pop up when clicking inside the comment box.

Here's my suggestion to actually speed things up: ESGST makes a individual stylesheet with all the elements depending on the users settings per page. This gets stored in ESGST and replaces the original one whenever the page is loaded. As a result there's not much sorting after loading the page going on anymore as elements should pop up right where they belong in the first place. (No idea if this is technically possible.)

rafaelgomesxyz commented 6 years ago

Weird, I see a very noticeable difference here. Maybe it's because I use the extension. Obviously the comment box will not jump to the top immediately as the page loads, but it should jump quite faster than before.

That's the intended behavior for Comment Formatting Helper.

Your suggestion is not practical at all, and I don't think it's possible. The script cannot load before the page has loaded, so it has to wait for those 1-2 seconds to load. I do have an idea for something that could possibly speed it up, but it would be quite complex, so I haven't had time to test it out yet. Plus I don't believe 1-2 seconds is really that much to wait for the script to load.

Eiion commented 6 years ago

No, no noticeable difference. Maybe on slower connection where content takes longer to be loaded in.

I know, it wouldn't hurt if it was there from the start though.

Saying "I don't believe 1-2 seconds is really that much to wait." is never a good argument. Every second that is wasted with waiting is a wasted second. And even little things add up to a lot.

ESGST knows when we're on a steamgifts page - otherwise it wouldn't run on the page in the first place. Therefore it knows as soon as the page loads in and maybe there's a way to interfere with the normal loading process and slipping in another stylesheet. Again, I don't know. Anyways, if you can improve it then that's great. If not, well, then not :-)

rafaelgomesxyz commented 6 years ago

I have a pretty good connection and it's definitely noticeable here, so I don't think that's the case. Before it used to take 2-3 or more seconds for me, but now it takes 1-2 at most, sometimes even less.

I would say it is a very good argument, considering the huge amount of features that ESGST has. Waiting 1 second compared to using SteamGifts without ESGST is a very insignificant thing, in my opinion. But like I said, maybe you have it worse because you use the userscript and the extension is shown to have a better performance overall. In some pages the features load literally instantly for me.

I'm not really sure what you mean by "stylesheet". Stylesheets only contain CSS rules. If you mean the HTML content of the page, then it wouldn't change anything, because ESGST would still have to wait until the page has loaded to tamper with the HTML in any case. ESGST does know when you are on a SteamGifts page the moment you open it, but it has to wait for the HTML to load before it can start adding the elements.

gizellos commented 6 years ago

Eiion do you have any reason for using the script version? The extension version is noticeably faster. Try it.

rafaelgomesxyz commented 6 years ago

Check the latest dev version, it feels very instant for me now. ESGST now retrieves your storage while the page is loading and when the page loads it is ready to immediately start inserting elements.

Eiion commented 6 years ago

I was talking about the layout. Right now the page loads and afterwards ESGST changes the layout by moving the blocks around. If ESGST would inject the final layout earlier, with spaces reserved for where things eventually are going to be, then everything should pop up right were it belongs.

I'll have a look at the new dev version.

Eiion commented 6 years ago

It takes about 3 seconds to load in https://www.steamgifts.com/giveaway/AkLRT/johnsgame Right after loading I left clicked on the URL and then right clicked to copy it which took about 4 seconds to give me the context menu. That's new. Something's lagging things.

rafaelgomesxyz commented 6 years ago

Like I said, that is not possible. ESGST has to wait for the page to load.

Does it lag in any page?

Eiion commented 6 years ago

Any GA page.

Tested the extension - which is very noticeably faster. A friend tested it as well afterwards with the same results. It's giving an error though: "Unrecognized manifest key 'applications'."

(The reason for using the script over the extension is that I'm using the same account on several machines, all synched. Which means another extension slowing down the browser on older machines while with the script has no such effect. Also, no automatic update is a big bummer.)

rafaelgomesxyz commented 6 years ago

That's not an error, just a warning. It's used in Firefox, but has no use on Chrome, so it does not affect anything.

Eiion commented 6 years ago

Chrome extensions also make use of a manifest key. EDIT: https://developer.chrome.com/apps/manifest/key

rafaelgomesxyz commented 6 years ago

Not that one.

Eiion commented 6 years ago

Ok