{"id":17125241,"date":"2023-10-15T18:25:59","date_gmt":"2023-10-15T18:25:59","guid":{"rendered":"https:\/\/wordpress.org\/support\/?post_type=topic&#038;p=17125241"},"modified":"2023-10-15T19:02:52","modified_gmt":"2023-10-15T19:02:52","slug":"please-avoid-jquery","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/please-avoid-jquery\/","title":{"rendered":"Please, avoid jQuery"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Please refrain from assuming that jQuery is in use, especially when there isn&#8217;t much reason for it. For instance, the JS in the file &#8220;includes\/class-ctn-load-time.php&#8221; on line 80, instead of the code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ctn loadtime display\n(function($) {\n    $(document).on('ready', function () {\n        $('.ctn_load_time_in_sec').text(&lt;?php echo $this-&gt;load_time; ?&gt; + \" seconds\");\n    });\n})(jQuery)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s better to use vanilla js, which is also more elegant:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ctn loadtime display\ndocument.addEventListener('DOMContentLoaded', () =&gt; {\n    let o = document.querySelector('.ctn_load_time_in_sec');\n    o &amp;&amp; (o.textContent = <code>&lt;?= $this-&gt;load_time ?? &#039;unknown&#039; ?&gt; seconds<\/code>);\n});<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In any case, thank you for the plugin.<\/p>\n","protected":false},"template":"","class_list":["post-17125241","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/17125241","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":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/17125241\/revisions"}],"predecessor-version":[{"id":17125276,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/17125241\/revisions\/17125276"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=17125241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}