As Yi Jiang already stated, the "smallest" depends completely on your specific needs, if you want everything that Fancybox does, I hardly doubt that there's a way around using that very plugin.
Still you could take a look at others and see whether they fit your needs, you should check out this list of lightbox scripts, many of which are smaller in size than Fancybox, but you'll still have to evaluate them and see if they fit your needs.
And last but not least you can always write your own one by reading a tutorial. That is, if you want to write your own one. But then again, if you have such specific needs you should know that nobody will come along and write some code for you for free.
当我们讨论这个主题时,如果您正在寻找主要是为了减少浏览器获取时间的小脚本,那么还要确保您的 Web 服务器缓存控制标头和压缩设置设置为良好的值。您可以在此处找到一篇不错的文章(关于缓存)。如果您没有定义良好的缓存策略,那么如果在每个页面视图上都从服务器下载脚本,那么脚本是否小也没有多大关系。
My approach to these sort of problems is to find a script that meets my requirements then hack it mercilessly until it only contains what I need. Once that's achieved, I'll minify the script (leaving the compression of the script up to my server).
While we're on the subject, if you are looking for small scripts mainly to reduce the browser fetch time, then also ensure that your web server cache control headers and compression settings are set to good values. A nice writeup (regarding caching) can be found here. If you don't have a good caching policy defined, then it won't matter much whether the script is small if it is being downloaded from the server on every page view.
I would shy away from the PrettyPhoto plugin, which appears convenient. There is an advertisement on their demo which is suspicious (my site was redirected shortly after experimenting with it)
If you are looking for a lightbox, try to find one that has been updated to the latest query. Slimbox2 and fancy box have not been updated for modern css, using images to build the box, and neither have been updated for streamlining changes in the latest jquery.
发布评论
评论(5)
我编写了一个名为 Nitelite 的低级 jQuery 灯箱脚本: https://github.com/ premasagar/nitelite (缩小和压缩后为 1.4KB)
它是一种既可以单独使用,也可以构建功能更丰富的灯箱插件的东西。
它已在几个项目的生产中使用:
它是开源的,MIT 许可证。享受 ;)
I wrote a low-level jQuery lightbox script called Nitelite: https://github.com/premasagar/nitelite (it's 1.4KB when minified and gzipped)
It is the kind of thing that can be either used on its own, or to build more feature-rich lightbox plugins.
It's been used in production on a couple of projects:
It's open source, MIT license. Enjoy ;)
我曾经用过这个...
http://www.digitalia.be/software/slimbox2
只有4K啊
I have used this sometime ...
http://www.digitalia.be/software/slimbox2
It's only 4K .
正如 Yi Jiang 已经说过的,“最小”完全取决于您的具体需求,如果您想要 Fancybox 所做的一切,我几乎不怀疑有一种方法可以使用该插件。
您仍然可以看看其他人,看看它们是否满足您的需求,您应该查看此 lightbox 脚本列表,其中许多脚本的大小比 Fancybox 小,但您仍然需要评估它们并查看它们是否满足您的需求。
最后但并非最不重要的一点是,您始终可以通过阅读 教程。也就是说,如果您想编写自己的。但话又说回来,如果您有这样的特定需求,您应该知道没有人会免费为您编写一些代码。
As Yi Jiang already stated, the "smallest" depends completely on your specific needs, if you want everything that Fancybox does, I hardly doubt that there's a way around using that very plugin.
Still you could take a look at others and see whether they fit your needs, you should check out this list of lightbox scripts, many of which are smaller in size than Fancybox, but you'll still have to evaluate them and see if they fit your needs.
And last but not least you can always write your own one by reading a tutorial. That is, if you want to write your own one. But then again, if you have such specific needs you should know that nobody will come along and write some code for you for free.
我解决这类问题的方法是找到一个满足我的要求的脚本,然后无情地修改它,直到它只包含我需要的内容。一旦实现了这一点,我将缩小脚本(将脚本的压缩留给我的服务器)。
当我们讨论这个主题时,如果您正在寻找主要是为了减少浏览器获取时间的小脚本,那么还要确保您的 Web 服务器缓存控制标头和压缩设置设置为良好的值。您可以在此处找到一篇不错的文章(关于缓存)。如果您没有定义良好的缓存策略,那么如果在每个页面视图上都从服务器下载脚本,那么脚本是否小也没有多大关系。
My approach to these sort of problems is to find a script that meets my requirements then hack it mercilessly until it only contains what I need. Once that's achieved, I'll minify the script (leaving the compression of the script up to my server).
While we're on the subject, if you are looking for small scripts mainly to reduce the browser fetch time, then also ensure that your web server cache control headers and compression settings are set to good values. A nice writeup (regarding caching) can be found here. If you don't have a good caching policy defined, then it won't matter much whether the script is small if it is being downloaded from the server on every page view.
我会回避 PrettyPhoto 插件,它看起来很方便。他们的演示中有一则可疑的广告(我的网站在尝试后不久就被重定向了)
如果您正在寻找灯箱,请尝试找到一个已更新为最新查询的灯箱。 Slimbox2 和 fancy box 还没有针对现代 css 进行更新,使用图像来构建盒子,也没有针对最新 jquery 中的简化更改进行更新。
I would shy away from the PrettyPhoto plugin, which appears convenient. There is an advertisement on their demo which is suspicious (my site was redirected shortly after experimenting with it)
If you are looking for a lightbox, try to find one that has been updated to the latest query. Slimbox2 and fancy box have not been updated for modern css, using images to build the box, and neither have been updated for streamlining changes in the latest jquery.