{"id":128,"date":"2020-01-18T16:34:40","date_gmt":"2020-01-18T16:34:40","guid":{"rendered":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.oxyset.com\/?p=128"},"modified":"2022-05-13T20:01:19","modified_gmt":"2022-05-13T20:01:19","slug":"load-script-only-when-you-need-it","status":"publish","type":"post","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/load-script-only-when-you-need-it\/","title":{"rendered":"Load script only when you need it"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In code block when you are using script add to PHP tab:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\"><pre class=\"wp-block-cedaro-code line-numbers\"><code class=\"language-php\">&lt;?php \n\twp_enqueue_script( 'magic-grid', '\/wp-content\/plugins\/_NZP_Devs-Toolbox\/node_modules\/magic-grid\/dist\/magic-grid.min.js', '', '1.0.0', true );\n?>\t<\/code><\/pre><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You need to put path from \/wp-content\/ and not just plugins folder<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PHP<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/http\/code.oxyset.com\/wp-content\/uploads\/2020\/01\/Screenshot-2020-01-18-at-17.35.04-1024x387.png\" alt=\"\" class=\"wp-image-130\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/http\/code.oxyset.com\/wp-content\/uploads\/2020\/01\/Screenshot-2020-01-18-at-17.35.25-1024x447.png\" alt=\"\" class=\"wp-image-131\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Note: <em>Got this trick from a good friend Alexander Buzmakov. <br><\/em><a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/oxywp.com\/en\/\">Visit his tutorials oxywp.com.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In code block when you are using script add to PHP tab: You need to put path from \/wp-content\/ and not just plugins folder PHP JavaScript Note: Got this trick from a good friend Alexander Buzmakov. Visit his tutorials oxywp.com.<\/p>\n","protected":false},"author":1,"featured_media":46513,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Load script only when you need it - Code DPlugins","description":"In code block when you are using script add to PHP tab: You need to put path from \/wp-content\/ and not just plugins folder PHP JavaScript Note: Got this trick f"},"_slim_seo_primary_term_category":0,"_slim_seo_primary_term_post_tag":0,"footnotes":""},"categories":[16,7,3],"tags":[],"dpc_library":[],"class_list":["post-128","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery","category-oxygen","category-wordpress"],"_links":{"self":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":0,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media\/46513"}],"wp:attachment":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/tags?post=128"},{"taxonomy":"dpc_library","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/dpc_library?post=128"}],"curies":[{"name":"wp","href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}