Add multiple custom script in one js file for different wordpress page

I have written this script in a scripts.js file. And I want execute the first half for only Home page and second half for custom post type page. How can I do this in wordpress ?

 // This Chunk For Home Page  [Part one]
 jQuery("#front-page-slider").responsiveSlides({
              maxwidth: 390,
              "auto": true,
              "pager": false,
               "nav": false,
              "pause": true,
               speed: 800
          });



    // This Chunk is for For Only Custom Post Page [Part Two]
  $("a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'pp_default',slideshow:3000, autoplay_slideshow: false});
  var width = $(window).width();

Related posts

Leave a Reply

2 comments

  1. this is my idea:

    in the js:

    function PartOneForHome(){
    //code bla bla bla
    }
    function PartTwoForCustomPosts(){
    //code bla bla bla
    }
    

    in the header.php or footer.php:

    <?php if(is_home()) { ?>
      <script> PartOneForHome(); </script>
    <?php } else if is any custom post* { ?>
      <script> PartTwoForCustomPosts(); </script>
    <?php } ?>
    

    *I dont know how to detect if is a custom post, search for it 😀