我怎样才能减少jQuery? [英] How can I reduce jQuery?

查看:25
本文介绍了我怎样才能减少jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上只使用了一些基本的 jQuery 函数.
如何删除未使用的 jQuery 代码?
只知道基础知识,我看了代码,不知道从哪里开始.如果您能指出我正确的方向,我将不胜感激.

I'm using just a few basic jQuery functions on my site.
How can I remove unused jQuery code?
Knowing only the basics, I looked at the code and was not sure where to start. If you could point me in the right direction, that would be appreciated.

谢谢.

推荐答案

jQuery 本身并不是为了有选择地使用而构建的.它自己的功能之间有很多相互依赖关系,而且源代码的布局并不容易模块化.与使用 jQuery-UI 等插件的情况不同,jQuery 的核心几乎是接受或离开它.

jQuery itself isn't really built to be selectively used. There are lots of interdependencies between its own functions and the source isn't laid out to be easy to modularise. Unlike the situation with plugins like jQuery-UI, the core of jQuery is pretty much take-it-or-leave-it.

如果您只使用了几个简单的函数,您或许可以用纯 JavaScript 重写它们.如果您使用的主要功能是选择器,您可以使用 Sizzle,这是 jQuery 本身使用的底层选择器库.否则......不是真的.

If you've only used a few simple functions, you might be able to rewrite them in plain JavaScript. If the main function you're using is selectors you can use Sizzle, which is the underlying selector library that jQuery itself uses. Otherwise... not really.

这篇关于我怎样才能减少jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆