0

I've implemented JavaScript on wordpress and it only works after i re-size the window from the original size to a different size then back to the original size. I don't understand why it just doesn't work from the start?

Here is the script in the head

<script type="text/javascript" src="/wp-content/themes/dw-minion/assets/css/jstick/jquery.js"></script>
<script type="text/javascript" src="/wp-content/themes/dw-minion/assets/css/jstick/jquery.stickem.js"></script>
<script type="text/javascript">
  jQuery(document).ready(function($) {
    $('.container').stickem();
  });
</script>

The place the script is used in content.php inside the body

<div class="container">
  <div class="row stickem-container">
    <div class="content">
      <div class="entry-content"> 
        <a href="<?php the_permalink(); ?>"><?php the_content(); ?></a>
      </div>
    </div>
    <div class="aside stickem">
      <div class="sharepinterest">
        <?php echo get_simple_local_avatar( $id_or_email, $size, $default, $alt ); ?>
      </div>
    </div>
  </div>
</div>
putvande
  • 15,068
  • 3
  • 34
  • 50
Bioxcode
  • 179
  • 1
  • 2
  • 9

2 Answers2

0

Scripts should be enqueued for execution using wp_enqueue_script in functions.php file of your theme. This is the preferred method to enqueue scripts and style.

http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Perhaps this might be preventing your script from being executed right from start.

0

Would prefer to comment but don't have the reputation, please check here.

Running javascript after page is fully rendered

I had this issue prevsiouly as a script was being triggered before the page was rendered. Resizing the window, zooming in and out and also bringing up the chrome element inspector reszied the issue div.

Community
  • 1
  • 1
The Humble Rat
  • 4,586
  • 6
  • 39
  • 73