Sunday, 23 April 2017

How does my HTML page have access to socket.io on client-side?

I'm doing the socket.io chat tutorial and so far everything works. But I don't understand how the client-side is using socket.io code:

<!-- Load socket.io client-side -->
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>

    $(function (){

        var socket = io();

        $('form').submit(function(){
            socket.emit('chat message', $('#m').val());
            $('#m').val('');
            return false;
        });

        socket.on('chat message', function(msg){
            $('#messages').append($('<li>').text(msg));
        });

    });

So it's accessing it from "/socket.io/socket.io.js" but I don't have that anywhere in my folder. I don't get how the HTML webpage is accessing the socket.io.js file. Not sure how else to ask this. Where is this .js file?



via Aran Bins

No comments:

Post a Comment