From e1990e07c70fbeefc2fd3330ccf4727bcfc9f1e8 Mon Sep 17 00:00:00 2001
From: Paulus Schoutsen <paulus@paulusschoutsen.nl>
Date: Mon, 7 Dec 2015 20:12:07 -0800
Subject: [PATCH] Conditionally load webcomponents polyfill

---
 .../components/frontend/index.html.template      | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/homeassistant/components/frontend/index.html.template b/homeassistant/components/frontend/index.html.template
index 87c5f6638a7..c0631c9d9db 100644
--- a/homeassistant/components/frontend/index.html.template
+++ b/homeassistant/components/frontend/index.html.template
@@ -1,5 +1,5 @@
 <!doctype html>
-<html>
+<html lang="en">
   <head>
     <meta charset="utf-8">
     <title>Home Assistant</title>
@@ -31,11 +31,21 @@
         margin-bottom: 123px;
       }
     </style>
+    <link rel='import' href='/static/{{ app_url }}' async>
   </head>
   <body fullbleed>
     <div id='init'><img src='/static/favicon-192x192.png' height='192'></div>
-    <script src='/static/webcomponents-lite.min.js'></script>
-    <link rel='import' href='/static/{{ app_url }}' />
+    <script>
+      var webComponentsSupported = ('registerElement' in document &&
+                                    'import' in document.createElement('link') &&
+                                    'content' in document.createElement('template'))
+      if (!webComponentsSupported) {
+        var script = document.createElement('script')
+        script.async = true
+        script.src = '/static/webcomponents-lite.min.js'
+        document.head.appendChild(script)
+      }
+    </script>
     <home-assistant auth='{{ auth }}' icons='{{ icons }}'></home-assistant>
   </body>
 </html>
-- 
GitLab