Skip to content

Instantly share code, notes, and snippets.

@gunjanpatel
Created April 21, 2016 07:33
Show Gist options
  • Select an option

  • Save gunjanpatel/e2f4ac021293e020b9d640f0c22afec9 to your computer and use it in GitHub Desktop.

Select an option

Save gunjanpatel/e2f4ac021293e020b9d640f0c22afec9 to your computer and use it in GitHub Desktop.
shift redshop script on first
$document = JFactory::getDocument();

// Store document script in variable
$scripts = $document->_scripts;

// Clean document script head temporary
unset($document->_scripts);

// Find the redshop js to shift it up
$redshoJsKey = array_values(preg_grep("/\/redshop[-uncompressed]*.js/", array_keys($scripts)));

$i = 0;

// Rebuild document script
foreach ($scripts as $key => $value)
{
	// Forcing redshop js on top
	if ($i == 0)
	{
		$document->_scripts[$redshoJsKey[0]] = $scripts[$redshoJsKey[0]];
	}

	// Rest of the javascripts are here
	$document->_scripts[$key] = $value;

	$i++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment