WPIntell

Source evidence

Javascript Source File independent pages include?

Code Manager · support · 2024-07-28T19:37:00+00:00

complaintsentiment
mediumseverity
0.81relevance
1replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

6 / 19 rows with source links

31.6% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

13 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
CheriOR unresolved
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! 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

Comments

1 shown
Passionate Programmer Peter 2024-07-30T10:50:00+00:00

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