The MU forums have moved to WordPress.org

wp_enqueue_script problems (6 posts)

  1. Klark123
    Member
    Posted 14 years ago #

    HI, when using wp_enqueue_script in a plugin in WPMU, I've noticed a potential problem:

    When doing something like wp_enqueue_script('jquery'), each blog serves its own jquery file. That is, the jquery is served from the blog level and not the MU site level. In my case, I would like only one jquery served (so web browsers can download it once and cache it... as they surf the various blogs on my site)

    So, it's includign jquery like this:

    In /blog-name/

    <script type='text/javascript' src='http://blogs.somesite.com/blog-name/wp-includes/js/jquery/jquery.js?ver=1.3.2'></script>

    in /blog2-name/

    <script type='text/javascript' src='http://blogs.somesite.com/blog2-name/wp-includes/js/jquery/jquery.js?ver=1.3.2'></script>

    I can see where this might be desirable behavior in some cases. But, as an admin, it would be nice to have some control over this.

    Thanks-
    Bill

  2. Klark123
    Member
    Posted 14 years ago #

    I'd like to include it as:

    <script type='text/javascript' src='http://blogs.somesite.com/wp-includes/js/jquery/jquery.js?ver=1.3.2'></script>

  3. cafespain
    Member
    Posted 14 years ago #

    You can hook into the print_scripts action and look for jQuery entries and change the url, or look into using the Google ajax libraries (there are a couple of plugins to enable that) and serve them from Google CDN network.

  4. Klark123
    Member
    Posted 14 years ago #

    Thanks. i could always put the calls to google's jquery in my theme. But, then if I use a plugin that uses wp_enqueue_script, I'd end up with 2 jquery calls.

  5. cafespain
    Member
    Posted 14 years ago #

    That's why you should use one that hooks into wp_enquque_script

    http://wordpress.org/extend/plugins/search.php?q=google+ajax+libraries

  6. Klark123
    Member
    Posted 14 years ago #

    sounds good, thanks.

About this Topic

  • Started 14 years ago by Klark123
  • Latest reply from Klark123