浏览代码

move js to head and optimize for loading speed

Nick Sweeting 6 年之前
父节点
当前提交
e4c7683983
共有 2 个文件被更改,包括 39 次插入23 次删除
  1. 31 13
      archivebox/templates/index.html
  2. 8 10
      archivebox/templates/index_row.html

+ 31 - 13
archivebox/templates/index.html

@@ -116,7 +116,38 @@
             /*body[data-status~=running] .in-progress {
             /*body[data-status~=running] .in-progress {
                 display: inline-block;
                 display: inline-block;
             }*/
             }*/
+            tr td a.favicon img {
+                padding-left: 6px;
+                padding-right: 12px;
+                vertical-align: -4px;
+            }
+            tr td a.title {
+                font-size: 1.4em;
+                text-decoration:none;
+                color:black;
+            }
+            tr td a.title small {
+                background-color: #efefef;
+                border-radius: 4px;
+                float:right
+            }
         </style>
         </style>
+        <link rel="stylesheet" href="static/jquery.dataTables.min.css"/>
+        <script src="static/jquery.min.js"></script>
+        <script src="static/jquery.dataTables.min.js"></script>
+        <script>
+            document.addEventListener('error', function(e) {
+              e.target.style.opacity = 0;
+            }, true)
+            jQuery(document).ready(function() {
+                jQuery('#table-bookmarks').DataTable({
+                    stateSave: true, // save state (filtered input, number of entries shown, etc) in localStorage
+                    dom: '<lf<t>ip>', // how to show the table and its helpers (filter, etc) in the DOM
+                    order: [[0, 'desc']],
+                    iDisplayLength: 100,
+                });
+            });
+        </script>
     </head>
     </head>
     <body data-status="$status">
     <body data-status="$status">
         <header>
         <header>
@@ -161,18 +192,5 @@
             </center>
             </center>
             <br/>
             <br/>
         </footer>
         </footer>
-        <link rel="stylesheet" href="static/jquery.dataTables.min.css"/>
-        <script src="static/jquery.min.js"></script>
-        <script src="static/jquery.dataTables.min.js"></script>
-        <script>
-            jQuery(document).ready(function() {
-                jQuery('#table-bookmarks').DataTable({
-                    stateSave: true, // save state (filtered input, number of entries shown, etc) in localStorage
-                    dom: '<lf<t>ip>', // how to show the table and its helpers (filter, etc) in the DOM
-                    order: [[0, 'desc']],
-                    iDisplayLength: 100,
-                });
-            });
-        </script>
     </body>
     </body>
 </html>
 </html>

+ 8 - 10
archivebox/templates/index_row.html

@@ -1,18 +1,16 @@
-<tr data-url="$url">
-    <td title="Bookmarked timestamp: $timestamp">$bookmarked_date</td>
-    <td style="text-align: left">
-        <a href="$link_dir/$index_url" title="Link Index">
-            <img src="$link_dir/$favicon_url" onerror="this.style.opacity=0" class="link-favicon">
-        </a>
-        <a href="$link_dir/$archive_url" style="font-size:1.4em;text-decoration:none;color:black;" title="$title">
+<tr>
+    <td title="$timestamp">$bookmarked_date</td>
+    <td style="text-align:left">
+        <a href="$link_dir/$index_url"><img src="$favicon_url" class="link-favicon" decoding="async"></a>
+        <a href="$link_dir/$archive_url" title="$title">
             <span data-title-for="$url" data-archived="$is_archived">$title</span>
             <span data-title-for="$url" data-archived="$is_archived">$title</span>
-            <small style="background-color: #eee;border-radius:4px; float:right">$tags</small>
+            <small>$tags</small>
         </a>
         </a>
     </td>
     </td>
     <td>
     <td>
         <a href="$link_dir/$index_url">📄 
         <a href="$link_dir/$index_url">📄 
-            <span data-number-for="$url" title="Fetching any missing files...">$num_outputs <img src="static/spinner.gif" class="files-spinner"/></span>
+            <span data-number-for="$url" title="Fetching any missing files...">$num_outputs <img src="static/spinner.gif" class="files-spinner" decoding="async"/></span>
         </a>
         </a>
     </td>
     </td>
-    <td style="text-align: left"><!--🔗 <img src="$google_favicon_url" height="16px">--> <a href="$url">$url</a></td>
+    <td style="text-align:left"><a href="$url">$url</a></td>
 </tr>
 </tr>