This topic is locked
[SOLVED]

Custom_function.js Disabling on Some Pages

7/15/2021 6:56:32 PM
PHPRunner General questions
D
DRCR Dev author

Hi

Is it possible to to disable the custom_function.js on some pages?

I've solved high server load issues when the user is logged in, but the chat script is causing high server load on not logged in pages and I need to disable the custom_function.js on the register and login pages and in the suspended accounts custom menu page I created.

Thanks in advance for any help.

Cec

A
acpan 7/17/2021

For inspiration:

  1. Move the js codes/functions to a javascript file eg. my_functions.js and place it at the custom folder. You can do this at Editor Screen, at the bottom on the left where you can add custom files.


  2. then go to page designer and duplicate the current page and give a name, eg. myPage


  3. Finally, go to header.php,.at the editor screen, and echo the js script conditionally, based on the page name:



if ($_REQUEST["page"] == "myPage" )
{
echo '<script type="text/javascript" src="my_funtions.js"></script>';

}

Note: if you don't want to duplicate the page, you can also simply use php command parse_url() to parse the URL and include the js file based on the generated unique URL string of the page.

you can do the condition check both at the before process event of the page or header.php, if i am not wrong.

hope it helps.

D
DRCR Dev author 7/17/2021

Thank you that makes sense and this is great approach. I only want certain part of the site to have access to the chat and it gives that flexiability.

Thanks for your help ! :-)
Cec