{"id":19026073,"date":"2026-09-22T09:21:50","date_gmt":"2026-09-22T09:21:50","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/unnecessary-frontend-javascript-jquery-dependency\/"},"modified":"2026-09-22T09:21:50","modified_gmt":"2026-09-22T09:21:50","slug":"unnecessary-frontend-javascript-jquery-dependency","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/unnecessary-frontend-javascript-jquery-dependency\/","title":{"rendered":"Unnecessary frontend JavaScript \/ jQuery dependency"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi,<br \/>I noticed that the plugin enqueues <code>apd-public.js<\/code> with <code>jquery<\/code> as a dependency:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp_enqueue_script(\n    'apd-public',\n    APD_PLUGIN_URL . 'public\/js\/apd-public.js',\n    array( 'jquery' ),\n    APD_VERSION,\n    true\n);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This seems unnecessary because the functionality implemented in <code>apd-public.js<\/code> is <strong>already implemented in the plugin&#8217;s CSS<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The CSS already handles the checked state:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.apd-deposit-option input:checked + .apd-option-content .apd-option-radio {\n    border-color: #6366f1;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">So the plugin is currently loading an <strong>additional JavaScript file<\/strong>, <strong>jQuery<\/strong>, and consequently <strong>jQuery Migrate<\/strong>, just to implement functionality that is already covered by CSS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is especially problematic for modern WordPress sites using FSE\/block themes, where jQuery is generally not used on the frontend. Adding jQuery solely for this small visual interaction unnecessarily increases the frontend dependencies.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Is there a reason for keeping <code>apd-public.js<\/code> and the jQuery dependency here? From what I can see, this JavaScript can be removed without losing any functionality.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for looking into this!<\/p>\n","protected":false},"template":"","class_list":["post-19026073","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19026073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19026073\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19026073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}