| 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 });
|
| });
|
| })();
|
|
|