• I have a couple of javascript source files that I would like to limit to include only on specific website pages. If I enable them in Code Manaager, they are included on all pages, and one of them is necessary on one page of the site, but breaks the functionality of another page.

    Nothing comes to mind, without poring through both scripts to find the conflict – would be simpler to just not include the one resource file on the conflicting page… thoughts?

    I really am having fun with code manager, though. I can do all sorts of things I ‘want to do’ – like adding javascript and html within a PHP shortcode, just by using the “echo” command. And I don’t have to learn all the structure of WordPress to do it!!

    Thank you for this!

Viewing 1 replies (of 1 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @cherior

    Thank you for reaching out.

    Here are three suggestions which I hope might help:

    (1) It is not possible to limit javascript source files to specific pages, but if you need them on the front-end only, you can use a javascript shortcode instead of a javascript resource file. Would that work for you?

    (2) Alternatively, you can use php server code which allows you to check for specific pages. Not my preferred solutions but a possibility.

    (3) Generally it’s a good idea to add only javascript functions to a resource file. If you have two different resource files, you can give your functions different names to prevent conflicts. Would that help to solve the conflict?

    Thanks
    Peter

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.