Skip to content

Commit 45b516d

Browse files
committed
Speed-ups: reduce bundle size
1 parent d327371 commit 45b516d

File tree

12 files changed

+290
-161
lines changed

12 files changed

+290
-161
lines changed

components/LoveJunk.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
</a>
55
</template>
66
<script>
7-
import * as turf from '@turf/turf'
7+
import turfpoint from 'turf-point'
8+
import turfpolygon from 'turf-polygon'
9+
import turfbooleanPointInPolygon from '@turf/boolean-point-in-polygon'
810
911
export default {
1012
props: {
@@ -27,11 +29,11 @@ export default {
2729
show() {
2830
// We want to show the ad if the user's location is within the area LoveJunk cover.
2931
if (this.me && (this.me.lat || this.me.lng)) {
30-
// const point = turf.point([-0.1281, 51.508])
31-
// const point = turf.point([this.me.lng, this.me.lat])
32+
// const point = turfpoint([-0.1281, 51.508])
33+
// const point = turfpoint([this.me.lng, this.me.lat])
3234
// Disabled for now
33-
const point = turf.point([1, 2])
34-
const poly = turf.polygon([
35+
const point = turfpoint([1, 2])
36+
const poly = turfpolygon([
3537
[
3638
[0.5259425158394171, 51.55103377944621],
3739
[0.4710108752144171, 51.60906438228973],
@@ -85,7 +87,12 @@ export default {
8587
]
8688
])
8789
88-
return turf.booleanPointInPolygon(point, poly)
90+
console.log(
91+
'Check ',
92+
turfbooleanPointInPolygon,
93+
turfbooleanPointInPolygon(point, poly)
94+
)
95+
return turfbooleanPointInPolygon(point, poly)
8996
}
9097
9198
return false

components/MainHeader.vue

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
<b-navbar-toggle v-if="loggedIn" target="nav_collapse" />
1717
<b-collapse v-if="loggedIn" id="nav_collapse" ref="nav_collapse" is-nav class="flex-nowrap justify-content-between">
1818
<b-navbar-nav class="mainnav mainnav--left">
19-
<b-nav-item id="menu-option-mygroups" class="text-center small p-0 ml-2" to="/browse" @mousedown="maybeReload('/browse')">
19+
<b-nav-item id="menu-option-mygroups" no-prefetch class="text-center small p-0 ml-2" to="/browse" @mousedown="maybeReload('/browse')">
2020
<v-icon name="eye" scale="2" /><br>
2121
<span class="nav-item__text">Browse</span>
2222
</b-nav-item>
23-
<b-nav-item id="menu-option-give" class="text-center small p-0" to="/give" @mousedown="maybeReload('/give')">
23+
<b-nav-item id="menu-option-give" no-prefetch class="text-center small p-0" to="/give" @mousedown="maybeReload('/give')">
2424
<v-icon name="gift" scale="2" /><br>
2525
<span class="nav-item__text">Give</span>
2626
</b-nav-item>
27-
<b-nav-item id="menu-option-find" class="text-center small p-0" to="/find" @mousedown="maybeReload('/find')">
27+
<b-nav-item id="menu-option-find" no-prefetch class="text-center small p-0" to="/find" @mousedown="maybeReload('/find')">
2828
<v-icon name="shopping-cart" scale="2" /><br>
2929
<span class="nav-item__text">&nbsp;Ask</span>
3030
</b-nav-item>
31-
<b-nav-item id="menu-option-myposts" class="text-center small p-0" to="/myposts" @mousedown="maybeReload('/myposts')">
31+
<b-nav-item id="menu-option-myposts" no-prefetch class="text-center small p-0" to="/myposts" @mousedown="maybeReload('/myposts')">
3232
<div class="position-relative">
3333
<v-icon name="home" scale="2" /><br>
3434
<b-badge v-if="openPostCount" variant="info" class="mypostsbadge" :title="openPostCount | pluralize('open post', { includeNumber: true })">
@@ -37,7 +37,14 @@
3737
<span class="nav-item__text">My Posts</span>
3838
</div>
3939
</b-nav-item>
40-
<b-nav-item v-if="!simple" id="menu-option-chitchat" class="text-center small p-0" to="/chitchat" @mousedown="maybeReload('/chitchat')">
40+
<b-nav-item
41+
v-if="!simple"
42+
id="menu-option-chitchat"
43+
no-prefetch
44+
class="text-center small p-0"
45+
to="/chitchat"
46+
@mousedown="maybeReload('/chitchat')"
47+
>
4148
<div class="position-relative">
4249
<v-icon name="coffee" scale="2" /><br>
4350
<b-badge v-if="newsCount" variant="info" class="newsbadge" :title="newsCount | pluralize('unread ChitChat post', { includeNumber: true })">
@@ -46,11 +53,25 @@
4653
<span class="nav-item__text">ChitChat</span>
4754
</div>
4855
</b-nav-item>
49-
<b-nav-item v-if="!simple" id="menu-option-communityevents" class="text-center small p-0" to="/communityevents" @mousedown="maybeReload('/communityevents')">
56+
<b-nav-item
57+
v-if="!simple"
58+
id="menu-option-communityevents"
59+
no-prefetch
60+
class="text-center small p-0"
61+
to="/communityevents"
62+
@mousedown="maybeReload('/communityevents')"
63+
>
5064
<v-icon name="calendar-alt" scale="2" /><br>
5165
<span class="nav-item__text">Events</span>
5266
</b-nav-item>
53-
<b-nav-item v-if="!simple" id="menu-option-volunteering" class="text-center small p-0" to="/volunteerings" @mousedown="maybeReload('/volunteerings')">
67+
<b-nav-item
68+
v-if="!simple"
69+
id="menu-option-volunteering"
70+
no-prefetch
71+
class="text-center small p-0"
72+
to="/volunteerings"
73+
@mousedown="maybeReload('/volunteerings')"
74+
>
5475
<v-icon name="hands-helping" scale="2" /><br>
5576
<span class="nav-item__text">Volunteer</span>
5677
</b-nav-item>
@@ -63,21 +84,28 @@
6384
<b-navbar-nav class="mainnav mainnav--right">
6485
<NotificationOptions v-if="loggedIn" :distance="distance" :small-screen="false" :unread-notification-count.sync="unreadNotificationCount" @showAboutMe="showAboutMe" />
6586
<ChatMenu v-if="loggedIn" id="menu-option-chat" :is-list-item="true" :chat-count.sync="chatCount" />
66-
<b-nav-item v-if="!simple" id="menu-option-spread" class="text-center small p-0" to="/promote" @mousedown="maybeReload('/promote')">
87+
<b-nav-item
88+
v-if="!simple"
89+
id="menu-option-spread"
90+
no-prefetch
91+
class="text-center small p-0"
92+
to="/promote"
93+
@mousedown="maybeReload('/promote')"
94+
>
6795
<div class="position-relative">
6896
<v-icon name="bullhorn" scale="2" /><br>
6997
<span class="nav-item__text">Promote</span>
7098
</div>
7199
</b-nav-item>
72-
<b-nav-item id="menu-option-help" class="text-center small p-0" to="/help" @mousedown="maybeReload('/help')">
100+
<b-nav-item id="menu-option-help" no-prefetch class="text-center small p-0" to="/help" @mousedown="maybeReload('/help')">
73101
<v-icon name="question-circle" scale="2" /><br>
74102
<span class="nav-item__text">Help</span>
75103
</b-nav-item>
76-
<b-nav-item id="menu-option-settings" class="text-center small p-0" to="/settings" @mousedown="maybeReload('/settings')">
104+
<b-nav-item id="menu-option-settings" no-prefetch class="text-center small p-0" to="/settings" @mousedown="maybeReload('/settings')">
77105
<v-icon name="cog" scale="2" /><br>
78106
<span class="nav-item__text">Settings</span>
79107
</b-nav-item>
80-
<b-nav-item id="menu-option-logout" class="text-center p-0 small" @click="logOut">
108+
<b-nav-item id="menu-option-logout" no-prefetch class="text-center p-0 small" @click="logOut">
81109
<v-icon name="sign-out-alt" scale="2" /><br>
82110
<span class="nav-item__text">Logout</span>
83111
</b-nav-item>
@@ -86,7 +114,7 @@
86114
</client-only>
87115
<b-navbar-nav v-if="!loggedIn" class="ml-auto">
88116
<client-only>
89-
<b-nav-item>
117+
<b-nav-item no-prefetch>
90118
<div class="btn btn-white" @click="requestLogin">
91119
Sign&nbsp;in
92120
</div>
@@ -121,7 +149,7 @@
121149

122150
<b-navbar-nav>
123151
<client-only>
124-
<b-nav-item v-if="!loggedIn">
152+
<b-nav-item v-if="!loggedIn" no-prefetch>
125153
<div class="btn btn-white" @click="requestLogin">
126154
Sign in or Join
127155
</div>
@@ -137,19 +165,19 @@
137165
</div>
138166
<b-collapse v-if="loggedIn" id="nav_collapse_mobile" ref="nav_collapse_mobile" class="w-100 ourBack" is-nav>
139167
<b-navbar-nav class="ml-auto flex-row flex-wrap small">
140-
<b-nav-item class="text-center p-0" to="/browse" @mousedown="maybeReload('/browse')">
168+
<b-nav-item no-prefetch class="text-center p-0" to="/browse" @mousedown="maybeReload('/browse')">
141169
<v-icon name="eye" scale="2" /><br>
142170
<span class="nav-item__text">Browse</span>
143171
</b-nav-item>
144-
<b-nav-item class="text-center p-0" to="/give" @mousedown="maybeReload('/give')">
172+
<b-nav-item no-prefetch class="text-center p-0" to="/give" @mousedown="maybeReload('/give')">
145173
<v-icon name="gift" scale="2" /><br>
146174
<span class="nav-item__text">Give</span>
147175
</b-nav-item>
148-
<b-nav-item class="text-center p-0" to="/find" @mousedown="maybeReload('/find')">
176+
<b-nav-item no-prefetch class="text-center p-0" to="/find" @mousedown="maybeReload('/find')">
149177
<v-icon name="shopping-cart" scale="2" /><br>
150178
<span class="nav-item__text">Ask</span>
151179
</b-nav-item>
152-
<b-nav-item class="text-center p-0" to="/myposts" @mousedown="maybeReload('/myposts')">
180+
<b-nav-item no-prefetch class="text-center p-0" to="/myposts" @mousedown="maybeReload('/myposts')">
153181
<div class="position-relative">
154182
<v-icon name="home" scale="2" /><br>
155183
<b-badge v-if="openPostCount" variant="info" class="mypostsbadge2" :title="openPostCount | pluralize('open post', { includeNumber: true })">
@@ -158,7 +186,7 @@
158186
<span class="nav-item__text">My Posts</span>
159187
</div>
160188
</b-nav-item>
161-
<b-nav-item v-if="!simple" class="text-center p-0 white" to="/chitchat" @mousedown="maybeReload('/chitchat')">
189+
<b-nav-item v-if="!simple" no-prefetch class="text-center p-0 white" to="/chitchat" @mousedown="maybeReload('/chitchat')">
162190
<div class="position-relative">
163191
<v-icon name="coffee" scale="2" /><br>
164192
<b-badge v-if="newsCount" variant="info" class="newsbadge2" :title="newsCount | pluralize('unread ChitChat post', { includeNumber: true })">
@@ -167,27 +195,27 @@
167195
<span class="nav-item__text">ChitChat</span>
168196
</div>
169197
</b-nav-item>
170-
<b-nav-item v-if="!simple" class="text-center p-0" to="/communityevents" @mousedown="maybeReload('/communityevents')">
198+
<b-nav-item v-if="!simple" no-prefetch class="text-center p-0" to="/communityevents" @mousedown="maybeReload('/communityevents')">
171199
<v-icon name="calendar-alt" scale="2" /><br>
172200
<span class="nav-item__text">Events</span>
173201
</b-nav-item>
174-
<b-nav-item v-if="!simple" class="text-center p-0" to="/volunteerings" @mousedown="maybeReload('/volunteerings')">
202+
<b-nav-item v-if="!simple" no-prefetch class="text-center p-0" to="/volunteerings" @mousedown="maybeReload('/volunteerings')">
175203
<v-icon name="hands-helping" scale="2" /><br>
176204
<span class="nav-item__text">Volunteer</span>
177205
</b-nav-item>
178-
<b-nav-item v-if="!simple" class="text-center p-0" to="/promote" @mousedown="maybeReload('/promote')">
206+
<b-nav-item v-if="!simple" no-prefetch class="text-center p-0" to="/promote" @mousedown="maybeReload('/promote')">
179207
<v-icon name="bullhorn" scale="2" /><br>
180208
<span class="nav-item__text">Promote</span>
181209
</b-nav-item>
182-
<b-nav-item class="text-center p-0" to="/help" @mousedown="maybeReload('/help')">
210+
<b-nav-item no-prefetch class="text-center p-0" to="/help" @mousedown="maybeReload('/help')">
183211
<v-icon name="question-circle" scale="2" /><br>
184212
<span class="nav-item__text">Help</span>
185213
</b-nav-item>
186-
<b-nav-item class="text-center p-0" to="/settings" @mousedown="maybeReload('/settings')">
214+
<b-nav-item no-prefetch class="text-center p-0" to="/settings" @mousedown="maybeReload('/settings')">
187215
<v-icon name="cog" scale="2" /><br>
188216
<span class="nav-item__text">Settings</span>
189217
</b-nav-item>
190-
<b-nav-item class="text-center p-0" @click="logOut">
218+
<b-nav-item no-prefetch class="text-center p-0" @click="logOut">
191219
<v-icon name="sign-out-alt" scale="2" /><br>
192220
<span class="nav-item__text">Logout</span>
193221
</b-nav-item>
@@ -415,7 +443,7 @@ nav .navbar-nav li a.nuxt-link-active {
415443
max-width: 100%;
416444
}
417445
418-
/* These classes style the external b-nav-item-dropdown component */
446+
/* These classes style the external b-nav-item no-prefetch-dropdown component */
419447
.notiflist ::v-deep .dropdown-menu {
420448
height: 500px;
421449
overflow-y: auto;

components/ModGroupMap.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@
245245
<script>
246246
import map from '@/mixins/map.js'
247247
import ModChangedMapping from '@/components/ModChangedMapping'
248-
import * as turf from '@turf/turf'
248+
import turfpolygon from 'turf-polygon'
249+
import turfintersect from 'turf-intersect'
250+
import turfarea from 'turf-area'
249251
import Postcode from './Postcode'
250252
import SpinButton from './SpinButton'
251253
import ModGroupMapLocation from './ModGroupMapLocation'
@@ -413,18 +415,18 @@ export default {
413415
for (let i = 0; i < this.CGAs.length; i++) {
414416
for (let j = i + 1; j < this.CGAs.length; j++) {
415417
try {
416-
const p1 = turf.polygon(this.CGAs[i].json.coordinates)
417-
const p2 = turf.polygon(this.CGAs[j].json.coordinates)
418-
const intersection = turf.intersect(p1, p2)
418+
const p1 = turfpolygon(this.CGAs[i].json.coordinates)
419+
const p2 = turfpolygon(this.CGAs[j].json.coordinates)
420+
const intersection = turfintersect(p1, p2)
419421
420422
if (intersection) {
421-
if (turf.area(intersection) > 500) {
423+
if (turfarea(intersection) > 500) {
422424
console.log(
423425
'Intersection',
424426
i,
425427
j,
426428
intersection,
427-
turf.area(intersection)
429+
turfarea(intersection)
428430
)
429431
ret.push(intersection)
430432

components/ModGroupPostVisibility.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
</div>
7373
</template>
7474
<script>
75-
import * as turf from '@turf/turf'
75+
import turfbuffer from 'turf-buffer'
7676
import SpinButton from '~/components/SpinButton'
7777
7878
const OurToggle = () => import('~/components/OurToggle')
@@ -133,7 +133,7 @@ export default {
133133
const CGA = this.CGA
134134
135135
if (CGA) {
136-
return turf.buffer(CGA, this.scale, { units: 'meters' })
136+
return turfbuffer(CGA, this.scale, { units: 'meters' })
137137
} else {
138138
return null
139139
}

components/ModSettingsGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,13 +750,13 @@
750750
import GroupSelect from './GroupSelect'
751751
import ModSettingShortlink from './ModSettingShortlink'
752752
import GroupProfileImage from './GroupProfileImage'
753-
import OurFilePond from './OurFilePond'
754753
import ModGroupSetting from './ModGroupSetting'
755754
import SpinButton from './SpinButton'
756755
import NoticeMessage from './NoticeMessage'
757756
import ModSettingsGroupFacebook from './ModSettingsGroupFacebook'
758757
import ModGroupPostVisibility from './ModGroupPostVisibility'
759758
const ExternalLink = () => import('~/components/ExternalLink')
759+
const OurFilePond = () => import('~/components/OurFilePond')
760760
761761
const OurToggle = () => import('~/components/OurToggle')
762762

components/NewsReply.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@
219219

220220
<script>
221221
import NewsLovesModal from './NewsLovesModal'
222-
import OurFilePond from './OurFilePond'
223222
import SpinButton from './SpinButton'
224223
import twem from '~/assets/js/twem'
225224
@@ -232,6 +231,7 @@ import ProfileImage from '~/components/ProfileImage'
232231
const ProfileModal = () => import('~/components/ProfileModal')
233232
const ConfirmModal = () => import('~/components/ConfirmModal.vue')
234233
const NewsReplies = () => import('~/components/NewsReplies.vue')
234+
const OurFilePond = () => import('~/components/OurFilePond')
235235
236236
const AtTa = process.browser
237237
? require('vue-at/dist/vue-at-textarea')

components/NewsThread.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@
176176

177177
<script>
178178
import NewsReportModal from './NewsReportModal'
179-
import OurFilePond from './OurFilePond'
180179
import SpinButton from './SpinButton'
181180
import NewsReplies from '~/components/NewsReplies'
182181
import twem from '~/assets/js/twem'
@@ -195,6 +194,7 @@ import NewsPreview from '~/components/NewsPreview'
195194
import ProfileImage from '~/components/ProfileImage'
196195
197196
const ConfirmModal = () => import('~/components/ConfirmModal.vue')
197+
const OurFilePond = () => import('~/components/OurFilePond')
198198
199199
const AtTa = process.browser
200200
? require('vue-at/dist/vue-at-textarea')

mixins/isochrone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default {
3333
nelat = nelat === null ? thisne.lat : Math.max(nelat, thisne.lat)
3434
nelng = nelng === null ? thisne.lng : Math.min(nelng, thisne.lng)
3535
} catch (e) {
36-
console.log('WKT parse error', i.polygon)
36+
console.log('WKT parse error on isochrone', i.id)
3737
}
3838
})
3939

nuxt.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ module.exports = {
370370
build: {
371371
// analyze: true,
372372

373+
// Reduce size of CSS initial load.
374+
extractCSS: {
375+
ignoreOrder: true
376+
},
377+
373378
// When you deploy a new version, old chunk files which hadn't yet been loaded by a client will no longer
374379
// exist, and may cause errors. Nuxt has some rudimentary handling for this by reloading the whole page.
375380
// There are some suggestions from Sentry that this doesn't always work, and there is a suggestion that
@@ -425,7 +430,7 @@ module.exports = {
425430
maxInitialRequests: Infinity,
426431
automaticNameDelimiter: '.',
427432
name: true,
428-
minSize: 100000, // Change this to 0 if you're debugging problems and can't see which npm package is at fault.
433+
minSize: 0, // Change this to 0 if you're debugging problems and can't see which npm package is at fault.
429434
maxSize: 100000,
430435
cacheGroups: {
431436
vendor: {
@@ -655,7 +660,7 @@ module.exports = {
655660
},
656661

657662
router: {
658-
middleware: ['src']
663+
middleware: ['src'],
659664
},
660665

661666
sitemap: {

0 commit comments

Comments
 (0)