-
Notifications
You must be signed in to change notification settings - Fork 982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #14817 - load JS only in relevant pages #3466
Conversation
The proxy_status.js and about.js files should only be loaded on relevant pages.
I'm not sure, this ought to make it slower. For starters, by the time you're in /smart_proxies or /about , your browser should have fetched application.js. This means it's loaded from cache so it would take 0s to download it. Even if the browser downloads these two parallel (it does), it opens a new TCP connection and it will have to evaluate two scripts, so TTP (time to paint) is a bit higher. Why do you think this is a problem? |
It is true that loading another file may be slightly slower, but I think the difference will not be noticeable in a production environment. The reason I proposed this change is that we currently execute a lot of JS on every page load (in fact, almost all of our js gets executed for every |
+1 for loading the stuff only when it makes sense. I've seen the issues On Sat, Apr 30, 2016 at 2:46 PM, Tomer Brisker notifications@github.com
|
This is an important change. The proxy_status.js file has handlers attached to a general document event and a general window event. Since this file is concatonated into application.js, it is loaded and run on every page load. These event handlers are attached to every page and have side effects, some of which I've encountered. |
@tbrisker agreed 100%. I'm not a big fan of micro-optimization, especially if it goes against design benefits. |
@iNecas anything blocking this from being merge then? ;) |
Was waiting for @dLobatog to finish the discussion. Giving it day. |
@iNecas Thanks, I'll measure & post the results, sorry. I measured this kind of stuff a long time ago for http://projects.theforeman.org/issues/14117 and splitting JavaScript code even more added to the problem. These are not micro-optimizations, 'time to paint' can go down severely (1 second) when not all of the necessary JS code has been loaded. Give me until the end of today, and if I have not published measurements that support that, feel free to merge tomorrow morning or I can do it myself if it's not that much slower. |
Here are some measurements I did with the Chrome timeline:
I saved a few of the timelines in case you want to inspect them, but I did nothing fancy other than make Chrome save screenshots and measure paint in the Timeline tab of the devtools, also looked a bit at the network tab to see how it was retrieving these files. In any case it doesn't seem to make a major difference. Merging! |
Merged as ede1a30, thanks @tbrisker, also @iNecas @gailsteiger @ohadlevy ! |
The proxy_status.js and about.js files should only be loaded on relevant
pages.