Socket.io 脚本大小减小
socket.io 源脚本大约 70k,很大一部分是注释、空格...
我需要将该脚本缩小到更小的大小 有些脚本甚至没有空格,代码都在一起,这减少了脚本的原始大小。
socket.io 脚本的位置在哪里,以便我可以删除注释和空格? 或者是否有一个没有注释和空间的更小的socket.io?
socket.io source script goes like 70k, a great part is comments, spaces...
I need to reduce that script to a smaller size
Some scripts do not even have spaces and the code is all toghether, this reduces the script original size.
Where is the location of the socket.io script so that I can remove comments and spaces?
Or is there a socket.io allready whithout comments and spaces with a smaller size?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
socket.io 配置中有一个设置:
https:// github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO
您还可以在库上启用 gzip 压缩。
There is a setting in the socket.io configuration for this:
https://github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO
You may also enable gzip compression on the library.
客户端 .js 文件位于
*yourdir*/node_modules/socket.io/node_modules/socket.io-client/dist
中,有一个名为
socket.io.min.js 已经缩小了。
The client .js file is in
*yourdir*/node_modules/socket.io/node_modules/socket.io-client/dist
There is one file called
socket.io.min.js
which is minified already.OP 通过访问
/node_modules/socket.io/lib
并编辑“manager.js”,将“缩小”和“gzip 压缩”设置为“true”来解决该问题。他们必须这样做,因为他们使用的 nowJS 间接使用了“socket.io”,这将文件从 70k 减少到大约 4k!
The OP fixed the problem by going to
/node_modules/socket.io/lib
and editing 'manager.js', to set both "minification" and "gzip compression" to "true". They had to do this way because because they were using nowJS which indirectly uses 'socket.io'This reduced the file from 70k to about 4k!
看来socket.io要么返回一些其他文件,要么通过在运行时构建返回。
我通过重命名 min 来替换 socket.io.js。清除了浏览器的缓存,但仍然获取旧文件。
it seems socket.io is either returning some other file or returning by building at run time.
I replaced socket.io.js by renaming the min one. cleared cache of browser but still getting the old file.