Is it a good practice to send only specific javascript files from server side language to the browser only when the specific page needs it?

For ex. in PHP echoing a <script type="javascript" src"...
tag if a particular page is requested?