• I have relatively simple JavaScript I’d like to install on a single page of my blog. I’ve been reading various tutorials here and elsewhere and, unfortunately, all of them assume that I already have a basic understanding of how JavaScripts work within WP as well as the commands, which I do not.

    Assuming I want to install a script called “test.js”, please let me know if the following steps are correct?:

    STEP 1. Open my theme header.php and add this line of code:
    <script type=”text/javascript” src=”/scripts/test.js”></script>

    STEP 2. Create a new folder on my host called “scripts”. However, I’m unsure of the path? Should this new folder go into the general site folder or the sub admin folder containing all of the WP files?
    I also noticed that there is an existing JavaScript folder called “js”. Alternatively, should I just install the script here and set the source to: src=”/js/test.js” in Step 1 instead?

    STEP 3. Lastly, to call the script up, I assume I need to open the editor of the page where I want to have it installed and add the source code. Correct? If so (and this is where I’m having problems with the tutorials not being basic enough), would the following code be correct:?

    <div class=”test”>
    <script type=”text/javascript”><!–//–><![CDATA[//><!–
    test();
    //–><!]]></script>
    </div>

    Thanks for any and all advice.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Installing a basic JavaScript. Am I doing it right?’ is closed to new replies.