2

I hope use a CDN source as default, which doesn't load the local jquery.js while the CDN is OK. If the CDN doesn't reply, load the local jquery.js.

I have writted this in my template.php.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>!window.jQuery && document.write('<script src="<?php echo base_path().path_to_theme(); ?>/js/jquery.min.js"><\/script>');</script>

It worked well until I used the Flag module, which loads the flag.js file. I think this file just work with the version of jQuery that comes with Drupa, as it doesn't work with the jQuery library from Google CDN.

Did Drupal developers rewrite the whole jquery.js? I cant believe that.

What should I do to solve this problem? Can I fix it by rewriting flag.js? If it's possible I really don't want use other module such as the jQuery Update module; it is too huge.

3

No, Drupal devs didn't rewrite jQuery, a standard version is included (1.3.2). I can vouch for flag.js working fine with that version of jQuery.

It's not compatible with the version of jQuery that you're including though. You're probably also introducing a conflict between the two versions of the library that are included in the page.

jquery_update isn't a huge module at all, and it gives you several versions of jQuery plus the CDN option out of the box. It was written specifically to solve the problem you're trying to get round.

There's no good reason not to install it; if you don't, you'll just be reproducing functionality it already provides, which is time you could spend doing something productive.

  • 2
    Plus, the jQuery Update module comes with rewritten JavaScript files to use instead of Drupal core JavaScript files. I would rather use it, since it assures compatibility with future versions of the jQuery library. – kiamlaluno Oct 5 '13 at 12:32
  • 1
    Thanks, friend. I decide to use the jquery_update finally. Why not use a existing module to solve the problem instead of wasting time to code , YOLO! – vector Oct 5 '13 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.