fix: socket.io

- this makes it so socket.io only loads on home page where its needed for chatbox and not globally which was causing socket.io to load on all pages when it was not even needed. Thus a performance increase now.
This commit is contained in:
HDVinnie
2022-03-07 10:47:54 -05:00
parent adcef62cd5
commit 449555dab1
4 changed files with 22 additions and 20 deletions
-14
View File
@@ -45,20 +45,6 @@ if (token) {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
import Echo from 'laravel-echo';
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: process.env.MIX_ECHO_ADDRESS,
});
/*
* NPM Packages
*/
+13
View File
@@ -0,0 +1,13 @@
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
import Echo from 'laravel-echo';
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: process.env.MIX_ECHO_ADDRESS,
});
+7 -5
View File
@@ -6,16 +6,18 @@
@if (!auth()->user()->chat_hidden)
<div id="vue">
<script src="{{ mix('js/chat.js') }}" crossorigin="anonymous"></script>
@include('blocks.chat')
</div>
@endif
@include('blocks.featured')
@livewire('random-media')
@include('blocks.poll')
@include('blocks.top_torrents')
@include('blocks.top_uploaders')
@include('blocks.latest_topics')
@include('blocks.latest_posts')
@include('blocks.online')
{{--@include('blocks.top_torrents')--}}
{{--@include('blocks.top_uploaders')--}}
@include('blocks.latest_topics')
@include('blocks.latest_posts')
@include('blocks.online')
</div>
@endsection
+2 -1
View File
@@ -67,4 +67,5 @@ mix.options({
*/
.js('resources/js/unit3d/imgbb.js', 'public/js')
.js('resources/js/vendor/alpine.js', 'public/js')
.js('resources/js/vendor/virtual-select.js', 'public/js');
.js('resources/js/vendor/virtual-select.js', 'public/js')
.js('resources/js/unit3d/chat.js', 'public/js');