Title: Bug in code, pjntinit() can fail
Last modified: October 6, 2022

---

# Bug in code, pjntinit() can fail

 *  [o815](https://wordpress.org/support/users/o815/)
 * (@o815)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/bug-in-code-pjntinit-can-fail/)
 * Hi,
 * we had the issue that the ticker sometimes would not start to animate
 * after some logging i found out that pj-news-ticker is using the js code window
   onload inside document ready
 * after some digging on the intenet i found evidence that window.onload does in
   fact fire up before document ready but because of jquery implementation it can
   delay. especially if the page content is huge e.g. if you have an iframe inside,
   this will almost every time delay window.onload
 * long story short, we should never depend on document.ready, when we want to use
   window load.
 * so to fix the not running ticker we need to either move the window load part 
   outside of document ready, or (like in pj-news-ticker) remove the document ready
   part completely because it is not used for anything else…
 * so instead of this
 *     ```
       jQuery(document).ready(function ($) {
           // wait for fonts to load, to ensure correct width() calc
           $(window).bind("load", function () {
               console.log('step: inline document ready bind of load - pjnt-content & pjntinit()');
               $('.pjnt-content').pjntinit();
           });
       });
       ```
   
 * we need to do this
 *     ```
       // wait for fonts to load, to ensure correct width() calc
       jQuery(window).bind("load", function () {
           jQuery('.pjnt-content').pjntinit();
       });
       ```
   
 * i would like to get a comment from the plugin developer and if possible an update
   to the plugin so we dont need to modify the code ourselfs if there are any updates
   in the future…

The topic ‘Bug in code, pjntinit() can fail’ is closed to new replies.

 * ![](https://ps.w.org/pj-news-ticker/assets/icon-128x128.png?rev=1573723)
 * [PJ News Ticker](https://wordpress.org/plugins/pj-news-ticker/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pj-news-ticker/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pj-news-ticker/)
 * [Active Topics](https://wordpress.org/support/plugin/pj-news-ticker/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pj-news-ticker/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pj-news-ticker/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [o815](https://wordpress.org/support/users/o815/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/bug-in-code-pjntinit-can-fail/)
 * Status: not resolved