Forums

How to manually add a javascript file (4 posts)

  1. southstrandbikes
    Member
    Posted 2 years ago #

    I am trying to manually install a new javascript file called EasyDrag jQuery. The file name is jquery.easydrag.handler.beta2.js and its author's source page is here.

    Being new to WordPresss, I thought I could simply upload this file to my folder called /public_html/wp-includes/js/easydrag/ (I created the "easydrag" folder), then add a new line in the public_html/wp-includes/script-loader.php file. The line I added is:

    $scripts->add( 'easydrag', '/wp-includes/js/easydrag/jquery.easydrag.handler.beta2.js', false, '1.5.1');

    I cleared the browser cache and reloaded my wordpress home page. when viewing the source, there is no reference of the jquery.easydrag.handler.beta2.js file. What am I doing wrong?

  2. Aaron Jorbin
    Member
    Posted 2 years ago #

    the proper way to add a script is to use wp_enqueue_script . An article with some more explanation is at http://nickohrn.com/loading-javascript-libraries-in-wordpress-plugins-with-wp_enqueue_script/

  3. signupandmakemoney
    Member
    Posted 2 years ago #

    Thanks for this info, I mean the link, I've been looking for an answer like this for a while now.

  4. doc4
    Member
    Posted 2 years ago #

    southstrandbikes,

    It is also possible to use the Google service:

    <script src="http://www.google.com/jsapi"></script>
    <script> google.load("jquery", "1"); </script>

Topic Closed

This topic has been closed to new replies.

About this Topic