What's the best way to call jQuery scripts, in HTML/PHP template, or seperate js file?

Posted by j-man86 on Stack Overflow See other posts from Stack Overflow or by j-man86
Published on 2010-04-24T11:18:45Z Indexed on 2010/04/24 11:23 UTC
Read the original article Hit count: 225

Filed under:
|
|

StackOverflow is telling me this is a subjective question, but I think it's a matter of fact!

I have a number of scripts that I'm using on different parts of my site. In terms of making fewer http requests, I know it's better to combine all of these scripts into one .js file. However, isn't a waste of time for a page to call a .js full of 10 or 15 different functions when it's only using one?

The other method I am using is to use PHP conditional statements...

<?php if( is_page() ) { > 
     $(document).ready(function(){
          ...
     });
<?php } ?>

What's the best method or comination of these methods?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about php