Skip to content

Commit 34464d1

Browse files
committed
refactor layout to opitmize time to content
1 parent 825f31a commit 34464d1

File tree

7 files changed

+46
-45
lines changed

7 files changed

+46
-45
lines changed

themes/vue/layout/index.ejs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
Copyright &copy; 2014-<%- new Date().getFullYear() %> Evan You
6161
</div>
6262

63-
<script src="/js/common.js"></script>
6463
<script>
6564
var topScrolled = false
6665
window.addEventListener('scroll', function () {
@@ -72,4 +71,4 @@ window.addEventListener('scroll', function () {
7271
document.getElementById('mobile-bar').classList.add('top')
7372
}
7473
})
75-
</script>
74+
</script>

themes/vue/layout/layout.ejs

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717
<meta name="twitter:description" content="<%- theme.site_description %>">
1818
<meta name="twitter:image" content="https://<%- theme.root_domain %>/images/logo.png">
1919

20+
<link rel="icon" href="/images/logo.png" type="image/x-icon">
21+
2022
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600|Roboto Mono' rel='stylesheet' type='text/css'>
2123
<link href='//fonts.googleapis.com/css?family=Dosis:500&text=Vue.js' rel='stylesheet' type='text/css'>
22-
<link href="//cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css" rel='stylesheet' type='text/css'>
23-
<link rel="icon" href="/images/logo.png" type="image/x-icon">
24-
<script>
25-
window.PAGE_TYPE = "<%- page.type %>"
26-
</script>
24+
25+
<!-- main page styles -->
2726
<%- css(isIndex ? 'css/index' : 'css/page') %>
28-
<%- partial('partials/ga') %>
27+
28+
<!-- this needs to be loaded before guide's inline scripts -->
2929
<script src="/js/vue.js"></script>
30+
<script>window.PAGE_TYPE = "<%- page.type %>"</script>
3031
</head>
3132
<body class="<%- isIndex ? '' : 'docs' -%>">
3233
<div id="mobile-bar" <%- isIndex ? 'class="top"' : '' %>>
@@ -42,18 +43,50 @@
4243
<%- body %>
4344
<% } %>
4445
</div>
45-
<script src="//cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script>
4646
<script src="/js/smooth-scroll.min.js"></script>
47-
<script src="/js/common.js"></script>
4847
<% } else { %>
4948
<%- body %>
5049
<% } %>
5150

51+
<!-- main custom script for sidebars, version selects etc. -->
52+
<script src="/js/common.js"></script>
53+
54+
<!-- ga -->
55+
<script>
56+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
57+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
58+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
59+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
60+
61+
ga('create', '<%- theme.google_analytics %>', '<%- theme.root_domain %>');
62+
ga('send', 'pageview');
63+
</script>
64+
65+
<!-- search -->
66+
<link href="//cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css" rel='stylesheet' type='text/css'>
67+
<%- css('css/search') %>
68+
<script src="//cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script>
69+
<script>
70+
[
71+
'#search-query-nav',
72+
'#search-query-sidebar'
73+
].forEach(function (selector) {
74+
if (!document.querySelector(selector)) return
75+
docsearch({
76+
appId: 'BH4D9OD16A',
77+
apiKey: '85cc3221c9f23bfbaa4e3913dd7625ea',
78+
indexName: 'vuejs',
79+
inputSelector: selector
80+
})
81+
})
82+
</script>
83+
84+
<!-- fastclick -->
5285
<script src="//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js"></script>
5386
<script>
54-
document.addEventListener('DOMContentLoaded', function() {
55-
FastClick.attach(document.body);
56-
}, false);
87+
document.addEventListener('DOMContentLoaded', function() {
88+
FastClick.attach(document.body)
89+
}, false)
5790
</script>
5891
</body>
5992
</html>

themes/vue/layout/partials/ga.ejs

Lines changed: 0 additions & 9 deletions
This file was deleted.

themes/vue/source/css/index.styl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import "_common"
22
@import "_header"
3-
@import "_search"
43
@import '_sidebar'
54

65
$width = 900px

themes/vue/source/css/page.styl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@import "_common"
22
@import "_header"
33
@import "_demo"
4-
@import "_search"
54
@import "_sponsor"
65
@import "_migration"
76
@import "_sidebar"
@@ -111,7 +110,7 @@
111110
font-weight bold
112111
font-family $logo-font
113112
font-size 14px
114-
113+
115114
code
116115
background-color #efefef
117116

themes/vue/source/js/common.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(function () {
22

3-
initSearch()
43
initMobileMenu()
54
if (PAGE_TYPE) {
65
initVersionSelect()
@@ -74,25 +73,6 @@
7473
}
7574
}
7675

77-
/**
78-
* Swiftype search box
79-
*/
80-
81-
function initSearch () {
82-
[
83-
'#search-query-nav',
84-
'#search-query-sidebar'
85-
].forEach(function (selector) {
86-
if (!document.querySelector(selector)) return
87-
docsearch({
88-
appId: 'BH4D9OD16A',
89-
apiKey: '85cc3221c9f23bfbaa4e3913dd7625ea',
90-
indexName: 'vuejs',
91-
inputSelector: selector
92-
})
93-
})
94-
}
95-
9676
/**
9777
* Mobile burger menu button for toggling sidebar
9878
*/

0 commit comments

Comments
 (0)