Chromium Code Reviews| 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..9386b763635ca774928e12a2faa78253e0d6ca15 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 (let resourceUrl of RESOURCES_TO_LOAD) { |
| + let link = document.createElement('link'); |
|
achuithb
2016/05/05 20:18:31
we don't seem to use let in chromium. I'm wonderin
|
| + link.rel = 'import'; |
| + link.href = resourceUrl; |
| + document.head.appendChild(link); |
| + } |
| + }, { timeout: IDLE_TIMEOUT_MS }); |
| }); |
| })(); |