Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: ui/login/account_picker/user_pod_template.js

Issue 1925453005: Remove most of the loading delay for warning icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Remove let Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/login/account_picker/user_pod_template.js
diff --git a/ui/login/account_picker/user_pod_template.js b/ui/login/account_picker/user_pod_template.js
index 7853c5e0f67883b671ed983c17e3bd93344e6966..3a1e6c1c02e4b786b6bad6746a76e28aa56f76d4 100644
--- a/ui/login/account_picker/user_pod_template.js
+++ b/ui/login/account_picker/user_pod_template.js
@@ -5,22 +5,24 @@
(function() {
"use strict";
- var START_LOADING_DELAY = 1000;
-
- function doLazyLoad() {
- function lazyLoadUrl(url) {
- var link = document.createElement('link');
- link.rel = 'import';
- link.href = url;
- document.body.appendChild(link);
- }
-
- lazyLoadUrl('chrome://resources/polymer/v1_0/iron-icons/iron-icons.html');
- lazyLoadUrl(
- 'chrome://resources/polymer/v1_0/paper-button/paper-button.html');
- }
+ var RESOURCES_TO_LOAD = [
+ 'chrome://resources/polymer/v1_0/iron-icons/iron-icons.html',
+ 'chrome://resources/polymer/v1_0/paper-button/paper-button.html'
+ ];
+ /* const */ var IDLE_TIMEOUT_MS = 200;
window.addEventListener('load', function() {
- setTimeout(doLazyLoad, START_LOADING_DELAY);
+ // The user pod template gets cloned shortly after the load event to make
+ // the actual user pods. It then takes a few update cycles to style these
+ // elements. Loading polymer will block the DOM, so we try to load polymer
+ // after the user pods have been cloned and styled.
+ requestIdleCallback(function() {
+ for (var resourceUrl of RESOURCES_TO_LOAD) {
+ var link = document.createElement('link');
+ link.rel = 'import';
+ link.href = resourceUrl;
+ document.head.appendChild(link);
+ }
+ }, { timeout: IDLE_TIMEOUT_MS });
});
})();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698