Bug 29295 - Page specific jQuery
Summary: Page specific jQuery
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-20 22:44 UTC by Christopher Brannon
Modified: 2021-12-20 22:28 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.