Title: wp_enqueue_script and custom TablePress settings
Last modified: August 22, 2016

---

# wp_enqueue_script and custom TablePress settings

 *  Resolved [Darek L](https://wordpress.org/support/users/darekl/)
 * (@darekl)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/)
 * Hi Tobias,
 * I finished the backup plugin (I have 21 buttons already with scheduling auto 
   backup for kkstar ratings as well ;D). It need some more testing of course but
   all buttons work fine.
 * But now I want make some more corrections in my custom template for wordpress
   website. I want to use `wp_enqueue_script` for custom TablePress sort settings.
   Before I had HTML entry with my custom TablePress file just before footer close
   tag. The sort depends on datatables. So `jquery.datatables.min.js` need to be
   loaded before custom TablePress sort settings.
 * I saw that in TablePress plugin (`controller-frontend.php` file) the file `jquery.
   datatables.min.js` is enqueued with handle `tablepress-datatables`.
 * Now when I set dependencies of `tablepress-datatables` everything works fine 
   and my custom TablePress settings is loaded just after the `jquery.datatables.
   min.js`.
 * It that correct? The handle `tablepress-datatables` will not change in the future?
   Maybe it will be more safe back to the old solution and place it in HTML link
   tag just before footer?
 * Regards,
    Darek
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402920)
 * Hi Darek,
 * no, that handle will probably not change, but I still don’t recommend to use 
   that.
    Instead, use a filter hook like `tablepress_all_datatables_commands` to
   append setting, or change the parameters via `tablepress_datatables_parameters`.
   The better approach would however likely be to just enqueue the DataTables JS
   library yourself, as TablePress will only ever register and enqueue it in the
   frontend part of the site.
 * Regards,
    Tobias
 *  Thread Starter [Darek L](https://wordpress.org/support/users/darekl/)
 * (@darekl)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402922)
 * Tobias,
 * Why don’t recommend that? What about `wp_enqueue_script`, is it all bad idea?
 * >  Instead, use a filter hook like tablepress_all_datatables_commands to append
   > setting, or change the parameters via tablepress_datatables_parameters.
 * What do You mean by filter hook? However I am not sure if it is possible to do
   that by changing TablePress settings. First I have to get kkstar ratings directly
   from db via AJAX and then when table is loaded sort using new values readable
   for TablePress. This is how it goes shortly… I use `fnSort` with custom `sType`.
 * >  DataTables JS library yourself
 * Not will be loaded twice?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402936)
 * Hi,
 * no, don’t get me wrong, I’m not discouraging using `wp_enqueue_script`. I guess
   I was just confused by what exactly you are trying to do.
    If the approach with`
   wp_enqueue_script` works for you, keep using it, of course! I just want to stress
   that there’s no guarantee that TablePress will actually register the script, 
   as it will only do so when it needs it.
 * Regards,
    Tobias
 *  Thread Starter [Darek L](https://wordpress.org/support/users/darekl/)
 * (@darekl)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402941)
 * Tobias, actually I don’t see any other solution except that one above with the
   handle or just use `<link>` HTML tag just after `wp_footer()` as I had before;-(
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402947)
 * Hi,
 * ok, then definitely keep using that method. A fixed `<link>` is bad.
 * Regards,
    Tobias
 *  Thread Starter [Darek L](https://wordpress.org/support/users/darekl/)
 * (@darekl)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402956)
 * Tobias, thanks. The `wp_enqueue_script` is more recommended for wordpress, so
   this is why I want to use it now instead of the `<link>` HTML tag. I guess the
   key is to set the dependencies correctly and allow wordpress do the rest. However,
   I don’t use the `wp_register_script`, only `wp_enqueue_script`. Bad?
 * I hope the handle will not be changing so often and all dependencies will be 
   loaded as they should 😉
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402959)
 * Hi,
 * just using `wp_enqueue_script` is totally fine. You don’t have to use `wp_register_script`
   explicitly. WordPress will call that from `wp_enqueue_script` automatically if
   necessary.
 * Regards,
    Tobias
 *  Thread Starter [Darek L](https://wordpress.org/support/users/darekl/)
 * (@darekl)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402960)
 * OK. Thanks.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402964)
 * Hi,
 * sure, no problem!
 * Best wishes,
    Tobias

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

The topic ‘wp_enqueue_script and custom TablePress settings’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [datatables](https://wordpress.org/support/topic-tag/datatables/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)
 * [wp_enqueue_script](https://wordpress.org/support/topic-tag/wp_enqueue_script/)

 * 9 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/wp_enqueue_script-and-custom-tablepress-settings/#post-5402964)
 * Status: resolved