<i id='xKut4'><tr id='xKut4'><dt id='xKut4'><q id='xKut4'><span id='xKut4'><b id='xKut4'><form id='xKut4'><ins id='xKut4'></ins><ul id='xKut4'></ul><sub id='xKut4'></sub></form><legend id='xKut4'></legend><bdo id='xKut4'><pre id='xKut4'><center id='xKut4'></center></pre></bdo></b><th id='xKut4'></th></span></q></dt></tr></i><div id='xKut4'><tfoot id='xKut4'></tfoot><dl id='xKut4'><fieldset id='xKut4'></fieldset></dl></div>

    1. <small id='xKut4'></small><noframes id='xKut4'>

      <legend id='xKut4'><style id='xKut4'><dir id='xKut4'><q id='xKut4'></q></dir></style></legend>
          <bdo id='xKut4'></bdo><ul id='xKut4'></ul>
      1. <tfoot id='xKut4'></tfoot>

        Jquery *编译器*可能吗?

        时间:2023-10-12
          <bdo id='UD3C9'></bdo><ul id='UD3C9'></ul>
            <tbody id='UD3C9'></tbody>

          • <i id='UD3C9'><tr id='UD3C9'><dt id='UD3C9'><q id='UD3C9'><span id='UD3C9'><b id='UD3C9'><form id='UD3C9'><ins id='UD3C9'></ins><ul id='UD3C9'></ul><sub id='UD3C9'></sub></form><legend id='UD3C9'></legend><bdo id='UD3C9'><pre id='UD3C9'><center id='UD3C9'></center></pre></bdo></b><th id='UD3C9'></th></span></q></dt></tr></i><div id='UD3C9'><tfoot id='UD3C9'></tfoot><dl id='UD3C9'><fieldset id='UD3C9'></fieldset></dl></div>

              1. <tfoot id='UD3C9'></tfoot>
                <legend id='UD3C9'><style id='UD3C9'><dir id='UD3C9'><q id='UD3C9'></q></dir></style></legend>
                1. <small id='UD3C9'></small><noframes id='UD3C9'>

                  本文介绍了Jquery *编译器*可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当我看到 这个问题时,我想如果可以编写 jQuery compiler 将会很有帮助.现在,编译器是指接收 jQuery 代码并输出最终执行的原始 javascript 代码的东西.

                  When I saw this question I thought it would be helpful if a jQuery compiler could be written. Now, by compiler, I mean something that takes in jQuery code and outputs raw javascript code that is ultimately executed.

                  这就是我对 jQuery 代码执行块的设想:

                  This is how I vision a block of jQuery code execution:

                  1. 调用一个 jQuery 函数并将参数传递给它
                  2. 该函数调用一个原始的 javascript 函数并将它收到的参数传递给它
                  3. 新调用的函数执行预期的操作

                  我知道这是一个非常简化的模型,它可能要复杂得多,但我认为复杂性降低到重复第 2 步和第 3 步,并调用不同的原始 js 函数,并且每个使用所有或部分参数/先前结果的时间.

                  I understand that this is a very simplified model and it could be much more complex, but I think the complexity is reduced to steps 2 and 3 being repeated with different raw js functions being called and each time fed with all or a subset of parameters / previous results.

                  如果我们订阅该模型,那么我们可能会想出一些方法来让 jQuery 函数执行双重任务:

                  If we subscribe to that model, then we might come up with methods to make the jQuery functions perform double-duty:

                  1. 他们已经做了什么
                  2. raw_function(passed_pa​​rams)
                  3. 的形式记录他们所做的事情
                  1. What they already do
                  2. Logging what they did in form of raw_function(passed_params)

                  我是否做出了一些错误的假设,使这成为不可能?任何想法 Firebug 的探查器如何尝试获取函数名称?可以用在这里吗?

                  Am I making some wrong assumptions that would make this impossible? Any ideas how Firebug's profiler attempts to get function names? Could it be used here?

                  编辑

                  我的想法是制作一个输入/输出为的黑盒:

                  What I was thinking was making a black box with input / output as:

                  普通 jquery 代码[BB]如果你不使用库你会写的代码

                  • 我称它为编译器,因为您编译一次,然后就会使用生成的代码.
                  • 我认为它至少可以用于教育,也可能有其他用途.
                  • 人们说这会占用少量代码并输出大量代码;据我所知,这并没有违背预期的目的
                  • 人们说我会在页面渲染中添加一个额外的、不必要的步骤,鉴于最终只会使用生成的代码(并且可能仅用于学习),这是不正确的.
                  • 人们说javascript函数和jquery函数之间没有一对一的关系,并暗示这样的转换器太复杂了,可能不值得努力.我现在同意这一点.
                  • I called this a compiler, because you compiled once and then would use the resulting code.
                  • I argued that it could have at least educational use, and probably other uses as well.
                  • People said this would take in a small amount of code and output a huge mass; that does not defy the intended purpose as far as I see
                  • People said I'd be adding an extra, needless step to page rendering, which, given only the resulting code would ultimately be used (and probably be used just for studying), is not correct.
                  • People said there is no one-to-one relation between javascript functions and jquery functions, and implied such a converter would be too complicated and probably not worth the effort. With this I now agree.

                  谢谢大家!

                  推荐答案

                  我想你的意思是:如果你写

                  I think what you mean is: if you write

                  var myId = $("#myId")
                  

                  它将被转换为

                  var myId = document.getElementById("myId")
                  

                  我认为可能,但问题是,jQuery 函数返回 jQuery 对象,所以在上面的例子中,第一个 myId 将是一个 jQuery 对象 &第二个将是一个节点对象(我认为),它将影响编译后在代码中稍后需要使用它的其他功能.特别是如果他们被锁住了

                  I think its possible, but the problem is, jQuery functions return jQuery objects, so in the above example, the first myId will be a jQuery object & the second will be a node object(i think) which will affect other functions that needs to use it later in the code after compilation. Especially if they are chained

                  其次,您必须确保转换确实具有性能优势.但是,如果您了解所有这些并且可以相应地计划您的代码,我认为这是可能的

                  secondly you will have to be sure that the conversion actually has performance benefits. However if you are aware of all this and you can plan you code accordingly, i think it will be possible

                  这篇关于Jquery *编译器*可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:除了 Objective-J 之外,还有其他语言可以“编译 下一篇:将字符串计算为 JavaScript 中的数学表达式

                  相关文章

                  最新文章

                  <small id='QkdB9'></small><noframes id='QkdB9'>

                  <legend id='QkdB9'><style id='QkdB9'><dir id='QkdB9'><q id='QkdB9'></q></dir></style></legend>
                    <bdo id='QkdB9'></bdo><ul id='QkdB9'></ul>

                2. <tfoot id='QkdB9'></tfoot>
                  <i id='QkdB9'><tr id='QkdB9'><dt id='QkdB9'><q id='QkdB9'><span id='QkdB9'><b id='QkdB9'><form id='QkdB9'><ins id='QkdB9'></ins><ul id='QkdB9'></ul><sub id='QkdB9'></sub></form><legend id='QkdB9'></legend><bdo id='QkdB9'><pre id='QkdB9'><center id='QkdB9'></center></pre></bdo></b><th id='QkdB9'></th></span></q></dt></tr></i><div id='QkdB9'><tfoot id='QkdB9'></tfoot><dl id='QkdB9'><fieldset id='QkdB9'></fieldset></dl></div>