Bug 29295

Summary: Page specific jQuery
Product: Koha Reporter: Christopher Brannon <cbrannon>
Component: System AdministrationAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook, emmi.takkinen, fridolin.somers, gmcharlt
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Christopher Brannon 2021-10-20 22:44:05 UTC
Would love it if there was an option laid out, just like sql reports, where we could list jQuery modifications.  We would have a global tab for each module (internet, OPAC, Self-Check, etc.) and then we could pick a specific page and have jQuery that was just for that page.  That way if you have jQuery that only deals with a specific page, it would only load with that page, and not be loaded in the background when on all the other pages it will never apply to.  This would also help organize modifications as well.
Comment 1 Fridolin Somers 2021-12-18 09:27:52 UTC
You mean JQuery code added in IntranetUserJS or OPACUserJS ?

Each page as an id in the body.
For example :
<body id="main_intranet-main" class="intranet-main">

So you can create a code loaded just for that page with :
  if ( $("body#main_intranet-main").length > 0 ) {
Comment 2 Christopher Brannon 2021-12-20 16:20:17 UTC
(In reply to Fridolin Somers from comment #1)
> You mean JQuery code added in IntranetUserJS or OPACUserJS ?
> 
> Each page as an id in the body.
> For example :
> <body id="main_intranet-main" class="intranet-main">
> 
> So you can create a code loaded just for that page with :
>   if ( $("body#main_intranet-main").length > 0 ) {

That solution is a logical selector.  I am talking about jquery that will only be loaded for specific pages.  If you look at ANY page source in Koha, you will always see ALL of your jQuery, not just jQuery that relates to that page.

Some libraries have a lot of jQuery, and an enhancement of this nature would A) reduce the amount of code that is looked at and processed when the page is loaded, and B) reduce unexpected side effects of jQuery that might affect unintended pages due to mistakes in the Koha or jQuery code.