Hello,
I cannot find this anywhere. I am using the Virtuemart Cart and Virtuemart Products modules. But these modules are loading Javascript that I am not using. Is it possible to disable loading the scripts in these modules?
/update_cart.js
/cvfind.js
/vmprices.js
/vmsite.js
I understand I need these scripts on the product details page, but i am not making use of these functions in my modules and also not on the category page. I'd like to outright disable loading them on these modules and category page because it hurts my page speed.
These files total only 24Kb - if that is too much why not just minify them, then they will total about 15Kb and load quicker. I use https://jscompress.com to compress js files.
Quote from: jenkinhill on January 27, 2023, 12:55:18 PM
These files total only 24Kb - if that is too much why not just minify them, then they will total about 15Kb and load quicker. I use https://jscompress.com to compress js files.
I'd like to outright disable loading them. I understand it's not much but if it isn't used why load it at all?
they are loaded as general dependences of VM.. you would need to detect in
administrator\components\com_virtuemart\helpers\vmjsapi.php if it were a VM page or a Joomla page then exclude what u don't want to load
If u really want to get a**l you could detect whether cart/detail/cat etc and if customfields were enabled on cats etc etc
Quote from: GJC Web Design on January 27, 2023, 15:09:46 PM
they are loaded as general dependences of VM.. you would need to detect in
administrator\components\com_virtuemart\helpers\vmjsapi.php if it were a VM page or a Joomla page then exclude what u don't want to load
If u really want to get a**l you could detect whether cart/detail/cat etc and if customfields were enabled on cats etc etc
Thank you for the response. I have added the following code:
$jinput = JFactory::getApplication()->input;
if($jinput->get('option') == "com_virtuemart"){
}
And then added the scripts into it to only load it when the virtuemart component is loaded. I did this for the prices scirpt in vmjsapi and in the customfield.php override i made for the cvfind script. And I outright removed the script from the virtuemart cart. Unfortunately with updates these changes will be overwritten. Anyone has an idea for that?
system plugin which you detect the correct pages and unset the JS file by file
something like this would remove prices.js
you would need additional filtering
/**
* Remove VM vmprices.js
*
*/
function onAfterRender() {
if (JFactory::getApplication()->isSite()) {
$body = JResponse::getBody();
$body = preg_replace('#src="([\\\/a-zA-Z0-9_:\.-]*)vmprices\.js.*."#', 'GARBAGE', $body, -1, 1);
$output = $body;
JResponse::setBody($output);
}
}