简体   繁体   English

具有类似于jQuery功能的模块化Javascript库

[英]Modular Javascript library with functionality similar to jQuery

jQuery and similar libraries provide a number of useful APIs for DOM traversal and manipulation. jQuery和类似的库为DOM遍历和操纵提供了许多有用的API。 Where your site as high number of repeat visitors, their use is easily justified as caching will offset any bandwidth cost to the end user. 如果您的站点是大量重复访问者,那么使用它们很容易就可以证明其合理性,因为缓存将抵消最终用户的任何带宽成本。

In other cases visitors to the site might always be unique and thus the bandwidth penalty for these libraries can be too severe relative to the benefits for a development team. 在其他情况下,该站点的访问者可能始终是唯一的,因此,相对于开发团队的利益而言,这些库的带宽损失可能过高。

Are there any libraries that provide this style of DOM interaction while allowing you to choose the parts relevant to your page. 是否有提供这种DOM交互样式的库,同时允许您选择与页面相关的部分。

For example, 例如,

jQuery('#myId').addClass('error');

and many other APIs in jQuery can be replicated in a few lines of code, thus avoiding ~50kB of downloads. jQuery中的许多其他API可以用几行代码进行复制,从而避免了约50kB的下载。

So the question is, does a library exist that contains these functions with little dependency on other aspects of the library or will I need to create them myself as necessary? 因此,问题是,是否存在一个包含这些函数的库,而这些函数对库的其他方面几乎没有依赖性,还是我需要根据需要自己创建它们?

Are there mechanisms/tools available to break down existing libraries like jQuery into their minimal components? 是否有可用的机制/工具将jQuery之类的现有库分解为最少的组件?

As discussed here , if you use google as a host of the libraries, the user probably already has it cached before they ever get to your site. 作为讨论在这里 ,如果你使用谷歌作为库的主机,用户可能已经有它,他们曾经让您的网站之前缓存。

This page shows you which libraries are supported. 该页面显示支持哪些库。 Currently: 目前:

  • jQuery jQuery的
  • jQuery UI jQuery UI
  • Prototype 原型
  • script.aculo.us script.aculo.us
  • MooTools Moo工具
  • Dojo 道场
  • SWFObject New! SWFObject 新!
  • Yahoo! 雅虎! User Interface Library (YUI) New! 用户界面库(YUI) 新!

I'm all for rolling your own, but be sure you know all the bugs of all the browser versions if you don't use a library. 我全力以赴,但如果您不使用库,请确保您知道所有浏览器版本的所有错误。

Not a bad idea, though. 不过,这不是一个坏主意。 It would be nice if you could create a custom version of jQuery. 如果您可以创建自定义版本的jQuery,那就太好了。 I'd especially like one for iPhone's Mobile Safari and Adobe AIR that stripped out all the non-webkit stuff. 我特别想要一款用于iPhone的Mobile Safari和Adobe AIR的软件,它可以剔除所有非webkit的内容。

The production version of jQuery is 19k, same as a rather small image. jQuery的生产版本为19k,与相当小的图像相同。 Not a severe bandwidh penalty in my book! 在我的书中不是严厉的带风刑!

Edit : ..and worth every k, too. 编辑 :..也值得每k。

MooTools allows you to download only the pieces you want. MooTools允许您仅下载所需的片段。 So if all you want is enough for JSON AJAX requests, you've got it. 因此,如果您只需要满足JSON AJAX请求,就可以了。

http://mootools.net/core http://mootools.net/core

Sorry guys I somehow lost the page in which one was asking about JS libraries conflicts solution. 抱歉,我以某种方式迷失了其中一个正在询问JS库冲突解决方案的页面。

I had the same problem but now I solved it after playing around with some JQuery scripts. 我遇到了同样的问题,但是现在我在玩了一些JQuery脚本后解决了。 I know it is a bit pain in * but lets do it step by step. 我知道*有点痛苦,但请逐步进行。

First of all let me tell you that in my project I am using two different libraries. 首先让我告诉您,在我的项目中,我正在使用两个不同的库。 I am using Lightwindow and JQuery. 我正在使用Lightwindow和JQuery。 I couldn't make both of the libraries function properly BUT I came up with the following script. 我无法使两个库都正常运行,但是我想出了以下脚本。 You have to use this script within each function that is meant to be using the JQuery functions: 您必须在每个要使用JQuery函数的函数中使用此脚本:

//This line says, that dollar sign $ is belongs to the JQuery library. //此行说,美元符号$属于JQuery库。

jQuery(document).ready(function($) { //Your source code goes here. jQuery(document).ready(function($){//您的源代码在这里。

}); });

Lets use it in little bit detailed. 让我们稍微详细地使用它。 In my scenario I am having a click button that suppose to call the following function: 在我的场景中,我有一个单击按钮,该按钮应该调用以下函数:

        function popups(message, heading, actionlink, linkName) {  

//This is the LINE that tell the rest of the source code //to recognize JQuery functions. //这是LINE,告诉其他源代码//识别JQuery函数。

            jQuery(document).ready(function($) {

            // get the screen height and width    
            var maskHeight = $(document).height();    
            var maskWidth = $(window).width();  


            // assign values to the overlay and dialog box  
            $('#dialog-overlay').css({height:maskHeight, width:maskWidth}).show();  
            $('#dialog-box1').show();  


            // display the message  
            $('#dialog-message-row').html(message);  
            $('#dialog-message-heading').html(heading);  
            $('#dialog-message-actionlink').html("<a onclick=function('x') class='button' id='delete'>"+linkName+"</a>");

           });//CLOSE JQuery translator
        }

Check out Sly . 退房Sly Only 3kB. 只有3kB。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM