确定组合的 js 文件中包含哪些脚本
我正在尝试构建一个ajax脚本加载器,但是我遇到了一个问题,我将组合文件的各个部分发送了两次以上(即jquery与其他脚本捆绑在一起,因为需要而发送了两次以上)通过一些(ajax)请求的脚本通过网络发送,
我的第一个想法是我只需将 md5 块附加到文件名上,如果请求的脚本与其中的一部分匹配,则不要发送 - 但这不能很好地扩展。比方说.. 100 个捆绑脚本。
还有其他建议吗?
谢谢
!
I'm trying to build an ajax script loader, but I'm running into the issue where I'm sending pieces of my combined file over twice (ie. jquery, bunched up with other scripts, is getting sent over twice because it's required by some (ajax) requested script sent over the wire.
My first thought was that I would just append md5 chunks onto the file name and if the requested script matches a piece of that, don't send - but this doesn't scale well for say.. 100 bundled scripts.
Anyone have any other suggestions?
Thanks!
Matt Mueller
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这取决于脚本类型。就我个人而言,我会定义可用的库,然后测试该对象是否已定义。
这里的 WAG 示例,就在我的脑海中(在我看来,定期使用这种方法可能非常令人发指,但比单独识别文本要快。)
I think it depends on the script types. Personally I'd define the libraries that are available and then just test to see if the object has been defined.
WAG example here, just off the top of my head (in my opinion this method could be pretty heinous to use on a regular basis but would be faster than individually identifying text.)