• Resolved dunkkan

    (@dunkkan)


    Hello,

    In order to speed the rest of the site, I’d like to load several scripts only in the front page.
    I though in make a traditional html page as a front page, then linking to the Blog itself to do that, but since I need to display the lastest posts right there, it’s no a good idea.

    So my question is : can I load in the header several scripts only in the front-page, using some conditional tag ?

    By scripts I mean both libraries and the scripts the library will need to display these or that.

    Two things so:

    1- how to load libraries only in the front page header ?
    2- how to load their scripts only in the front page header ?

    Well, that’s all folks ! Thanks for any tip.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Conditional_Tags that page should have the answers.

    Thread Starter dunkkan

    (@dunkkan)

    Thanks a lot Moshu,

    If I understand it well, this code in the header should do the work (I’m not sure at all about the php syntax):

    <?php if(!is_front_page()){ ?>
    
    <!-- the path for the library -->
    <script type="text/javascript" src="library/jquery-1.2.6.min.js"></script>
    
    <!-- a little script or script's path -->
    <script type="text/javascript">
    function mouseOver()
    {
    document.titre.src ="images/title2.png";
    }
    function mouseOut()
    {
    document.titre.src ="images/title.png";
    }
    </script>
    
    <!-- and several other scripts / script's paths here -->
    
    <?php } ?>

    Is it sure to go this way ?
    I mean, to save some bandwith, what it’s better: call for the script’s paths or write them all along the html ?

    I am not a coder either – but I’d say it should work.
    Except the relative path to the JS. That never works, try absolute.

    (That’s why I have a local WP installation on XAMPP so that I can test all kind of ideas, code, themes etc…)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘only load a script in the front page’ is closed to new replies.