How to run several versions of Zepto.js on one page?

Can someone please explain to me how I can make different assemblies for Zepto.js (in order to enable touch support) in a friendly manner because I cannot find detailed instructions anywhere on the Internet.

+4
source share
1 answer

This should work just like jQuery does:

<script src="zepto1.0.js"></script> <script> var zep10 = window.Zepto; </script> <script src="zepto0.8.js"></script> <script> var zep08 = window.Zepto; </script> 

Zepto does not need to "compile". It just needs to be placed in a variable, for example, jQuery and MooTools are included in $ by default. You can set the most frequently used version of Zepto to $ if you want:

 <script src="zepto1.0.js"></script> <script> var $ = window.Zepto; </script> 

Off course, you will need to run your teams from these objects from now on.

For version 1.0 you simply use your usual $.() Operations. But for version 0.8 you have to use zep08.() To call actions.

Note

From the Zepto homepage ( http://zeptojs.com ):

💔 Zepto will only install $ global if it is not already defined. There is no Zepto.noConflict method.

So, if you already downloaded jQuery or MooTools, it will not break the $ binding if you load these libraries before Zepto does. Otherwise, you will still overwrite.

Test

Also check this out: http://jsperf.com/qwery-vs-jquery-vs-mootools-selector-engines/11 . On Chrome and Safari, jQuery benefits from Zepto. This way you may have an easier “bootstrap” with Zepto, but it seems that jQuery wins in performance.

I tested on Safari 6.0.3 on Mac OS X 10.8.3 with these results:

Jeesh / id

  • JESH ("# N-Content");
  • 40,136 | ± 3.78% | 95% slower

jQuery / ID

  • JQuery ("# ​​N-content");
  • 765 799 | ± 4.36% | quick

Zepto / ID

  • Zepto ("# N-content");
  • 348 956 | ± 4.89% | 55% slower

Jeesh / class

  • Jayesh ("firstHeading");
  • 40,748 | ± 3.96% | 95% slower

jQuery / class

  • JQuery ("firstHeading.");
  • 306 591 | ± 4.31% | 60% slower

Zepto / class

  • Zepto ("firstHeading.");
  • 284 822 | ± 3.92% | 63% slower
+5
source

All Articles