Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Detecting if the head tag has a particular script
Is there a way to check if the head tag has a script. for eg
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript">
0
This discussion has been closed.
Comments
function headcontrol_checkforscript(&$Head,$myScript) { $found = false; foreach ($Head->Scripts as $value) { if ($value == $myScript) $found = true; } if (!$found) { $Head->AddScript($myScript); } $Context->AddToDelegate('Head', 'PreRender', 'headcontrol_checkforscript');
the AddScript should disallow duplicate scripts. If the script is already in the Scripts array, it should skip an attempt to put duplicate ones
of course u can always hack/modify the Head class yourself by adding this to the first line of the AddScript function:
if (in_array($ScriptLocation,$this->Scripts)) return;
edited to ScriptLocation