Title: widget breaks when attempting to load javascript asynchronously
Last modified: August 30, 2016

---

# widget breaks when attempting to load javascript asynchronously

 *  Resolved anonymized-14239226
 * (@anonymized-14239226)
 * [11 years ago](https://wordpress.org/support/topic/widget-breaks-when-attempting-to-load-javascript-asynchronously/)
 * I’d like to try exempting loading asynchronously the javascript for this plugin.
   
   What is the path/filename for it?
 * Thanks!
 * [https://wordpress.org/plugins/top-shared-posts-on-facebook/](https://wordpress.org/plugins/top-shared-posts-on-facebook/)

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

 *  anonymized-13749270
 * (@anonymized-13749270)
 * [11 years ago](https://wordpress.org/support/topic/widget-breaks-when-attempting-to-load-javascript-asynchronously/#post-6220160)
 * Hi [@blair](https://wordpress.org/support/users/blair/),
 * Please discuss more on this issue, how does the widget break, and why you want
   to load the JS asynchronously ?
 * The JavaScript the widget is using, is not saved in a .js file but it is included
   in the main PHP file because we wanted to use a PHP function there..
 * Check out this [SVN file](http://plugins.svn.wordpress.org/top-shared-posts-on-facebook/tags/0.1.3/top-shared-posts-on-facebook.php)
   for the plugin, search for “<script>” and that’s where you can find the script
   used to load this widget..
 * Anyways, are you sure the not async. loaded JS is the problem behind the widget
   breaking for you? How many total posts do you have?
 *  Thread Starter anonymized-14239226
 * (@anonymized-14239226)
 * [11 years ago](https://wordpress.org/support/topic/widget-breaks-when-attempting-to-load-javascript-asynchronously/#post-6220161)
 * Thanks. I’ll look into it.
    You want to load JS asynchronously to load your page
   faster and more efficiently. See: [https://developers.google.com/speed/pagespeed/insights](https://developers.google.com/speed/pagespeed/insights)
 *  Thread Starter anonymized-14239226
 * (@anonymized-14239226)
 * [11 years ago](https://wordpress.org/support/topic/widget-breaks-when-attempting-to-load-javascript-asynchronously/#post-6220162)
 * forgot this: By “break” I mean it fails to stop at the X number you choose to
   show and loads all on the page.
 *  anonymized-13749270
 * (@anonymized-13749270)
 * [11 years ago](https://wordpress.org/support/topic/widget-breaks-when-attempting-to-load-javascript-asynchronously/#post-6220164)
 * Thank you for the optimization advice. Unfortunately I can’t throw the JavaSrcipt
   in a separate external file as a part of it includes a PHP function which won’t
   be executed once the file isn’t a `.php` one.
 * The function is `<?php echo tspf_default_post_count(); ?>` : You can replace 
   it with a number of your choice, then load the JS async.
 * Once the plugin is updated, I am afraid you’ll do this process again.
 *  Thread Starter anonymized-14239226
 * (@anonymized-14239226)
 * [11 years ago](https://wordpress.org/support/topic/widget-breaks-when-attempting-to-load-javascript-asynchronously/#post-6220285)
 * Unfortunately that method doesn’t work.
 *  Thread Starter anonymized-14239226
 * (@anonymized-14239226)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/widget-breaks-when-attempting-to-load-javascript-asynchronously/#post-6220383)
 * If you use the “Async JS and CSS” plugin and choose to Load Javascript asynchronously,
   you can exempt the js for the TSPF in Exceptions.
    Placing these in the exceptions
   box appears to resolve this. jquery jquery.min.js
 *  anonymized-13749270
 * (@anonymized-13749270)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/widget-breaks-when-attempting-to-load-javascript-asynchronously/#post-6220384)
 * [@blair](https://wordpress.org/support/users/blair/),
 * Glad to hear you are resolved with the optimization trick.
 * We will publish a new plugin that includes this top shared posts as one of its
   features, and it is not going to use any JS.
 * > Placing these in the exceptions box appears to resolve this.
 * Marking as resolved – you did it 😉

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

The topic ‘widget breaks when attempting to load javascript asynchronously’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/top-shared-posts-on-facebook_fdfdfe.
   svg)
 * [Top Shared Posts on Facebook Widget](https://wordpress.org/plugins/top-shared-posts-on-facebook/)
 * [Support Threads](https://wordpress.org/support/plugin/top-shared-posts-on-facebook/)
 * [Active Topics](https://wordpress.org/support/plugin/top-shared-posts-on-facebook/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/top-shared-posts-on-facebook/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/top-shared-posts-on-facebook/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: anonymized-13749270
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/widget-breaks-when-attempting-to-load-javascript-asynchronously/#post-6220384)
 * Status: resolved