I'm creating a website in Joomla and wondering if there is a way to load a specific script in a specific page using php....
e.g. i want to load a :
<script src="sample.js">
in the about us page where it is going to be use
the reason why I wanted to do this is that instead of having them all load in head section even if it is not being use in the page makes page slower...
Are you trying to do this in a content item or a component? If you're trying to do it in a component, this is the way to add a JavaScript file to the head portion for only that page:
If you're trying to do this in a content item, you'll most likely need to find or build a content plugin to scan for a token that tells Joomla to run code like above. I did this on one of the sites I built a while back. I had it set so that a plugin would search for tags like {js sample.js} in content items, extract the file name, add the script to the document, then search and replace the tag out of the article.