0

How to use multiple jQuery Plugins in one File? I have to use jCarousel and Lightbox plugin both together in a file of php. the jCarousel is working fine for the light box all paths are correct but it always says that

$("#gallery a").lightbox is not a function. 

Same as for fancy box or how do I can use Lightbox2 of prototype with jQuery.

I used the below for no confliction

var $jx = jQuery.noConflict();
$jx(function() {
  $jx(".jgallery").jCarouselLite({
     btnNext: ".morePost",
     visible: 8,
     scroll:8   
  });

for using with prototype. The Prototype Light Box Start working but jCarousel does not work after this.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Jaguar
  • 403
  • 2
  • 10
  • 22
  • What exactly do you mean? Do you want to minimize/compact plugins into the same js file? Please clarify – Pekka Sep 21 '10 at 09:23
  • Related: [What do you use to minimize and compress JavaScript libraries?](http://stackoverflow.com/questions/1798315/how-can-i-compact-minimize-pack-my-javascript-closed) – Pekka Sep 21 '10 at 09:24
  • possible duplicate of [How to use multiple jQuery Plugins in one File](http://stackoverflow.com/questions/3758438/how-to-use-multiple-jquery-plugins-in-one-file) – BenMorel Jan 07 '14 at 16:01

2 Answers2

2

Allow me to suggest a different alternative here. If you're including Prototype just for the lightgox, don't :)

There's a jQuery version of the lightbox plugin, this will save you the weight on the user's download of 1/2 libraries. Just use the jQuery version here: http://avioli.github.io/jquery-lightbox/

There are a few variations out there, but no need to include 2 major JavaScript libraries that share similar plugins, just choose one and use the version of plugins that are built on it.

nikhil ponnuru
  • 288
  • 1
  • 6
  • 13
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
0

You can use a compiler to combine all your javascripts in one file. Famous ones are

Select your poison of choice. There are others you may want to investigate, even open source solutions that you can embed in your projects

samy
  • 14,832
  • 2
  • 54
  • 82
  • I have to use jcarasoul and Lightbox plugin both together in a file of php. the Jcarasoul is working fine for the light box all paths are correct but it always says that $("#gallery a").lightbox is not a funtion. Same as for fancy box or how do I can use Lightbox2 of prototype with jQuery. I used the below for no confliction var $jx = jQuery.noConflict(); $jx(function() { $jx(".jgallery").jCarouselLite({ btnNext: ".morePost", visible: 8, scroll:8 }); for using with prototype. The Prototype Light Box Start working but Jcarasoul not work after this. – Jaguar Sep 21 '10 at 10:08