Title: jQuery execution problem
Last modified: August 20, 2016

---

# jQuery execution problem

 *  [Lee Bolton](https://wordpress.org/support/users/leeb61982/)
 * (@leeb61982)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/jquery-execution-problem/)
 * I’m using the jquery.masonry.js script to display thumbnails in a brick style
   grid (see here for an explanation [http://masonry.desandro.com/](http://masonry.desandro.com/)).
 * I’m running into a bit of a strange problem. When the page first loads the thumbnails
   aren’t displayed properly, however when the page is refreshed everything works
   as expected.
 * If I clear the browser cache and reload it goes back to not working, and so on.
 * This makes me think that I’m doing something wrong with the way I’m enqueueing
   my js. This is what I have in my functions file, don’t see too much wrong with
   it.
 *     ```
       if (!is_admin()) {
       	wp_deregister_script( 'jquery' );
       	wp_register_script( 'jquery', get_bloginfo('stylesheet_directory').'/libs/jquery-1.6.1.min.js' );
       	wp_enqueue_script( 'jquery' );
       	wp_enqueue_script( 'jquery_ui', get_bloginfo('stylesheet_directory').'/libs/jquery-ui.custom.min.js' );
       	wp_enqueue_script( 'jquery_masonry', get_bloginfo('stylesheet_directory').'/libs/jquery.masonry.min.js' );
   
       }
       ```
   
 * I’d be interested to know if this problem can be replicated by other users and
   if so if anyone has a clue what might be wrong?
 * The URL is: [http://new.scratchpictures.co.uk/?page_id=17](http://new.scratchpictures.co.uk/?page_id=17)
 * Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael Bishop](https://wordpress.org/support/users/miklb/)
 * (@miklb)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/jquery-execution-problem/#post-2697102)
 * You wrap those in a function then execute via `add_action ('wp_enqueue_scripts','
   my_load_scripts');`
 * So:
 *     ```
       function my_load_scripts() {
       if (!is_admin()) {
       	wp_deregister_script( 'jquery' );
       	wp_register_script( 'jquery', get_bloginfo('stylesheet_directory').'/libs/jquery-1.6.1.min.js' );
       	wp_enqueue_script( 'jquery' );
       	wp_enqueue_script( 'jquery_ui', get_bloginfo('stylesheet_directory').'/libs/jquery-ui.custom.min.js' );
       	wp_enqueue_script( 'jquery_masonry', get_bloginfo('stylesheet_directory').'/libs/jquery.masonry.min.js' );
   
       }
       }
       add_action ('wp_enqueue_scripts', 'my_load_scripts');
       ```
   
 * See if that helps
 *  [Michael Bishop](https://wordpress.org/support/users/miklb/)
 * (@miklb)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/jquery-execution-problem/#post-2697103)
 * Also, I think `wp_enqueue_script('jquery');` loads the version of jquery bundled
   with WordPress , so you are loading it twice.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘jQuery execution problem’ is closed to new replies.

## Tags

 * [enqueue](https://wordpress.org/support/topic-tag/enqueue/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [script](https://wordpress.org/support/topic-tag/script/)
 * [thumbnails](https://wordpress.org/support/topic-tag/thumbnails/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [Michael Bishop](https://wordpress.org/support/users/miklb/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/jquery-execution-problem/#post-2697103)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
