{"id":283289,"date":"2021-02-25T15:19:44","date_gmt":"2021-02-25T15:19:44","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=283289"},"modified":"2025-05-28T10:41:15","modified_gmt":"2025-05-28T10:41:15","slug":"use-of-css-and-js-in-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/","title":{"rendered":"How to Use CSS and JS in Magento 2"},"content":{"rendered":"\n<p>In Magento 2, integrating CSS and JavaScript involves several steps. Here\u2019s a comprehensive guide to help you with the process:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">CSS :<\/h2>\n\n\n\n<p>Let&#8217;s first start with styling our pages. We will add styling to the add and edit page. But before that let&#8217;s add some div blocks and classes in our phtml files so that we can target them in css file.<\/p>\n\n\n\n<p>Let&#8217;s edit the add page, <em>view\/frontend\/templates\/add.phtml <\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/frontend\/templates\/add.phtml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;div class=&quot;blog-container&quot;&gt;\n    &lt;form class=&quot;blog-form&quot; method=&quot;post&quot; action=&lt;?= $escaper-&gt;escapeUrl($block-&gt;getUrl(&#039;blog\/manage\/save&#039;)); ?&gt; data-mage-init=&#039;{&quot;validation&quot;: {}}&#039;&gt;\n        &lt;div class=&quot;blog-form-field-container&quot;&gt;\n            &lt;span class=&quot;blog-form-field-label&quot;&gt;&lt;?=__(&#039;Title&#039;)?&gt;:&lt;\/span&gt;\n            &lt;input type=&quot;text&quot; name=&quot;title&quot; class=&quot;required-entry blog-form-field&quot;\/&gt;\n        &lt;\/div&gt;\n        &lt;div class=&quot;blog-form-field-container&quot;&gt;\n            &lt;span class=&quot;blog-form-field-label&quot;&gt;&lt;?=__(&#039;Content&#039;)?&gt;:&lt;\/span&gt;\n            &lt;textarea name=&quot;content&quot; class=&quot;required-entry validate-no-html-tags blog-form-field&quot;&gt;&lt;\/textarea&gt;\n        &lt;\/div&gt;\n        &lt;div class=&quot;blog-form-action-container&quot;&gt;\n            &lt;button type=&quot;submit&quot; class=&quot;blog-form-action&quot;&gt;&lt;?=__(&#039;Submit&#039;)?&gt;&lt;\/button&gt;\n        &lt;\/div&gt;\n    &lt;\/form&gt;\n&lt;\/div&gt;<\/pre>\n\n\n\n<p>Here as you can see we have added everything in html format and added classes to every element. And also we have made the static contents translatable.<\/p>\n\n\n\n<p>Similarly, we will need to change the edit page, <em>view\/frontend\/templates\/edit.phtml<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/frontend\/templates\/edit.phtml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n$blog = $block-&gt;getBlog();\n?&gt;\n&lt;div class=&quot;blog-container&quot;&gt;\n    &lt;form class=&quot;blog-form&quot; method=&quot;post&quot; action=&lt;?= $escaper-&gt;escapeUrl($block-&gt;getUrl(&#039;blog\/manage\/save&#039;)); ?&gt; data-mage-init=&#039;{&quot;validation&quot;: {}}&#039;&gt;\n        &lt;input type=&quot;hidden&quot; name=&quot;id&quot; value=&quot;&lt;?= $escaper-&gt;escapeHtml($blog-&gt;getId())?&gt;&quot;\/&gt;\n        &lt;div class=&quot;blog-form-field-container&quot;&gt;\n            &lt;span class=&quot;blog-form-field-label&quot;&gt;&lt;?=__(&#039;Title&#039;)?&gt;:&lt;\/span&gt;\n            &lt;input type=&quot;text&quot; name=&quot;title&quot; class=&quot;required-entry blog-form-field&quot; value=&quot;&lt;?= $escaper-&gt;escapeHtml($blog-&gt;getTitle()); ?&gt;&quot;\/&gt;\n        &lt;\/div&gt;\n        &lt;div class=&quot;blog-form-field-container&quot;&gt;\n            &lt;span class=&quot;blog-form-field-label&quot;&gt;&lt;?=__(&#039;Content&#039;)?&gt;:&lt;\/span&gt;\n            &lt;textarea name=&quot;content&quot; class=&quot;required-entry validate-no-html-tags blog-form-field&quot; rows=&quot;10&quot;&gt;&lt;?= $escaper-&gt;escapeHtml($blog-&gt;getContent()); ?&gt;&lt;\/textarea&gt;\n        &lt;\/div&gt;\n        &lt;div class=&quot;blog-form-action-container&quot;&gt;\n            &lt;button type=&quot;submit&quot; class=&quot;blog-form-action&quot;&gt;&lt;?=__(&#039;Submit&#039;)?&gt;&lt;\/button&gt;\n        &lt;\/div&gt;\n    &lt;\/form&gt;\n&lt;\/div&gt;<\/pre>\n\n\n\n<p>Now we have to create the css file. All the css and js files must be created under view\/{areacode}\/web folder. <\/p>\n\n\n\n<p>And it&#8217;s a convention to create separate folders for js and css files under the web folder. Also, it&#8217;s recommended to create only one css file for a module.<\/p>\n\n\n\n<p>So we will create the css file as <em>view\/frontend\/web\/css\/style.css<\/em><\/p>\n\n\n\n<p>Code for <em>view\/frontend\/web\/css\/style.css<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">.blog-form .blog-form-field-container {\n    margin: 15px auto;\n}\n.blog-form .blog-form-action-container {\n    text-align: center;\n}\n.blog-form .blog-form-action-container .blog-form-action {\n    min-width: 150px;\n    padding: 10px;\n    font-size: 16px;\n    background: #2b4c8a;\n    color: white;\n}<\/pre>\n\n\n\n<p>To use this CSS file on the edit and add blog pages we need to include this file in its layout file so Let&#8217;s edit their layout files.<\/p>\n\n\n\n<p>Let&#8217;s first change the add blog page&#8217;s layout file, <em>view\/frontend\/layout\/blogmanager_manage_add.xml<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/frontend\/layout\/blogmanager_manage_add.xml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n    &lt;update handle=&quot;customer_account&quot;\/&gt;\n    &lt;head&gt;\n\t&lt;css src=&quot;Webkul_BlogManager::css\/style.css&quot;\/&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n        &lt;referenceContainer name=&quot;content&quot;&gt;\n            &lt;block class=&quot;Magento\\Framework\\View\\Element\\Template&quot; name=&quot;blogmanager.blog.add&quot; template=&quot;Webkul_BlogManager::add.phtml&quot; \/&gt;\n        &lt;\/referenceContainer&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p>Here we have added &lt;head&gt; node and in that, we have added &lt;css&gt; node. The line <strong>src=&#8221;Webkul_BlogManager::css\/style.css&#8221;<\/strong> represents the source of the css file. <\/p>\n\n\n\n<p>Here we need to mention the css file path relative to the <em>view\/frontend\/web<\/em> folder.<\/p>\n\n\n\n<p>Now similarly we need to change the edit blog page&#8217;s layout file, <em>view\/frontend\/layout\/blogmanager_manage_edit.xml<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/frontend\/layout\/blogmanager_manage_edit.xml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n    &lt;update handle=&quot;customer_account&quot;\/&gt;\n    &lt;head&gt;\n\t\t&lt;css src=&quot;Webkul_BlogManager::css\/style.css&quot;\/&gt;\n\t&lt;\/head&gt;\n    &lt;body&gt;\n        &lt;referenceContainer name=&quot;content&quot;&gt;\n            &lt;block class=&quot;Webkul\\BlogManager\\Block\\Blog&quot; name=&quot;blogmanager.blog.edit&quot; template=&quot;Webkul_BlogManager::edit.phtml&quot; \/&gt;\n        &lt;\/referenceContainer&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p><br>Now if you check the pages you will find that the style is getting applied.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"581\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-1200x581.png\" alt=\"2021-02-24_19-25\" class=\"wp-image-283762\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-1200x581.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-300x145.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-250x121.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-768x372.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-1536x744.png 1536w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25.png 1647w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Please make sure to compile and flush the cache. You may need to hard-refresh if you change in css because browsers try to store css and js files locally.<\/p>\n\n\n\n<p>If still your css is not applied please run the following Magento commands.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">php bin\/magento setup:static-content:deploy<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript aka JS :<\/h2>\n\n\n\n<p>Magento usage requirejs for managing dependencies and optimizing the loading time. <\/p>\n\n\n\n<p>We will change the delete process and use ajax to delete the blogs. I will just show you basic js codes here. Please <a href=\"https:\/\/www.google.com\/search?q=javascript+magento+2+devdoc\" target=\"_blank\" rel=\"noreferrer noopener\">search<\/a> and study the concepts of js in Magento on your own. <\/p>\n\n\n\n<p>Let&#8217;s first create the js file, <em>view\/frontend\/web\/js\/bloglist.js<\/em><\/p>\n\n\n\n<p>Code for <em>view\/frontend\/web\/js\/bloglist.js<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">define(&#091;\n    &quot;jquery&quot;,\n    &#039;mage\/translate&#039;\n], function ($, $t) {\n    $(&#039;.blog-list-table .blog-list-table-action.blog-list-table-action-delete a&#039;).on(&#039;click&#039;, function(e){\n        var self=this;\n        e.preventDefault();\n        var url = $(self).attr(&#039;href&#039;);\n        $.ajax({\n            type: &quot;GET&quot;,\n            dataType: &quot;json&quot;,\n            url: url,\n            data: {},\n            beforeSend: function() {\n                $(&#039;body&#039;).trigger(&quot;processStart&quot;);\n            },\n            success: function (response) {\n                $(&#039;body&#039;).trigger(&quot;processStop&quot;);\n                $(self).closest(&#039;.blog-list-table-row&#039;).remove();\n            },\n            error: function (response) {\n                $(&#039;body&#039;).trigger(&quot;processStop&quot;);\n            }\n        })\n    })\n});<\/pre>\n\n\n\n<p>We will use the same structure in almost every js file. In the first param of <strong>define, <\/strong>we are mentioning our requirements.<\/p>\n\n\n\n<p>Here we have asked for <em>jquery<\/em> and <em>mage\/translate<\/em> libraries and the requirejs will load these libraries.<\/p>\n\n\n\n<p>The &#8220;<em>mage\/translate<\/em>&#8221; is used for translation purposes in js just like __(&#8220;&#8221;) in php files that we have already seen.<\/p>\n\n\n\n<p>In the second param, we have passed a function that has two arguments ($, $t). It corresponds to the libraries that we have requested. <\/p>\n\n\n\n<p>That means we can access jQuery with $ and the translation library with $t.<\/p>\n\n\n\n<p>Here we have used <em>$(&#8216;body&#8217;).trigger(&#8220;processStart&#8221;)<\/em> which will start the loader in Magento and once the ajax request is completed we have to stop the loader with <em>$(&#8216;body&#8217;).trigger(&#8220;processStop&#8221;)<\/em>. <\/p>\n\n\n\n<p>And almost everything else inside the anonymous function should be familiar to you because it is just jquery.<\/p>\n\n\n\n<p>Here we have used <strong>define<\/strong> but we can also use <strong>require<\/strong>. The <em>define<\/em> is used when we want the js to be used in another js file. <\/p>\n\n\n\n<p>For that, we have to do minor syntax changes. Please search for the difference between define and require, there are multiple blogs about them.<\/p>\n\n\n\n<p>In <a href=\"https:\/\/store.webkul.com\/Magento-2.html\">Magento 2<\/a>, we create aliases for the js files. For that we use <strong>requirejs-config.js<\/strong>, this config file has many other responsibilities too. <\/p>\n\n\n\n<p>But for now, we will just create the alias for our js file. The configuration file should be in <em>view\/frontend\/requirejs-config.js<\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Code for <em>view\/frontend\/requirejs-config.js<\/em> file<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\">var config = {\n    map: {\n        &#039;*&#039;: {\n            bloglist: &#039;Webkul_BlogManager\/js\/bloglist&#039;,\n        }\n    }\n};<\/pre>\n\n\n\n<p>The alias is <strong>bloglist<\/strong> for our <em>js\/bloglist.js<\/em> file which is the relative path from the <em>view\/frontend\/web\/<\/em> folder.<\/p>\n\n\n\n<p>Now let&#8217;s edit our list page to use this javascript, in <em>view\/frontend\/templates\/list.phtml<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/frontend\/templates\/list.phtml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;div class=&quot;blog-list-table-container&quot;&gt;\n    &lt;table class=&quot;blog-list-table&quot;&gt;\n        &lt;tr class=&quot;blog-list-table-head&quot;&gt;\n            &lt;th class=&quot;blog-list-table-id&quot;&gt;\n                &lt;?= __(&quot;Id&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-title&quot;&gt;\n                &lt;?= __(&quot;Title&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-content&quot;&gt;\n                &lt;?= __(&quot;Content&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-action-edit&quot;&gt;\n                &lt;?= __(&quot;Edit&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-action-delete&quot;&gt;\n                &lt;?= __(&quot;Delete&quot;)?&gt;\n            &lt;\/th&gt;\n        &lt;\/tr&gt;\n        &lt;?php\n        $blogs = $block-&gt;getBlogs();\n\n        foreach ($blogs as $blog) {?&gt;\n        &lt;tr class=&quot;blog-list-table-row&quot;&gt;\n            &lt;td class=&quot;blog-list-table-id&quot;&gt;\n                &lt;?= $escaper-&gt;escapeHtml($blog-&gt;getId())?&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-title&quot;&gt;\n                &lt;?= $escaper-&gt;escapeHtml($blog-&gt;getTitle())?&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-content&quot;&gt;\n                &lt;?= substr($escaper-&gt;escapeHtml($blog-&gt;getContent()), 0, 20).&#039;...&#039;?&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-action blog-list-table-action-edit&quot;&gt;\n                &lt;a href=&quot;&lt;?= $escaper-&gt;escapeUrl($block-&gt;getUrl(&#039;blog\/manage\/edit&#039;, &#091;&#039;id&#039;=&gt;$escaper-&gt;escapeHtml($blog-&gt;getId())]))?&gt;&quot;&gt;\n                    &lt;?= __(&#039;Edit&#039;) ?&gt;\n                &lt;\/a&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-action blog-list-table-action-delete&quot;&gt;\n                &lt;a href=&quot;&lt;?= $escaper-&gt;escapeUrl($block-&gt;getUrl(&#039;blog\/manage\/delete&#039;, &#091;&#039;id&#039;=&gt;$escaper-&gt;escapeHtml($blog-&gt;getId())]))?&gt;&quot;&gt;\n                    &lt;?= __(&#039;Delete&#039;) ?&gt;\n                &lt;\/a&gt;\n            &lt;\/td&gt;\n        &lt;\/tr&gt;\n        &lt;?php } ?&gt;\n    &lt;\/table&gt;\n&lt;\/div&gt;\n\n&lt;script type=&quot;text\/x-magento-init&quot;&gt;\n    {\n        &quot;*&quot;: {\n            &quot;bloglist&quot;: &quot;&quot;\n        }\n    }\n&lt;\/script&gt;<\/pre>\n\n\n\n<p>Here to call the js we need to use a script tag. We do not need to mention the full path of the js file, only the alias name is enough. <\/p>\n\n\n\n<p>Instead of * we can give an element to bind the js to that element.<\/p>\n\n\n\n<p>Also, we can pass JSON object to the js file by writing <strong>&#8220;bloglist&#8221;: {&#8220;msg&#8221;:&#8221;Hello&#8221;}<\/strong>. But let&#8217;s not make this complicated.<\/p>\n\n\n\n<p>I have also done some minor changes here like I have added classes and removed the confirm widget because we will implement it in the Magento way in the later part of this blog.<\/p>\n\n\n\n<p>We will also need to edit our delete action <em>Controller\/Manage\/Delete.php<\/em><\/p>\n\n\n\n<p>Updated code for <em>Controller\/Manage\/Delete.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Controller\\Manage;\n\nuse Magento\\Customer\\Controller\\AbstractAccount;\nuse Magento\\Framework\\App\\Action\\Context;\nuse Magento\\Customer\\Model\\Session;\n\nclass Delete extends AbstractAccount\n{\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\BlogFactory\n     *\/\n    protected $blogFactory;\n\n    \/**\n     * @var Magento\\Customer\\Model\\Session\n     *\/\n    protected $customerSession;\n\n    \/**\n     * @var \\Magento\\Framework\\Serialize\\Serializer\\Json\n     *\/\n    protected $jsonData;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param Context $context\n     * @param \\Webkul\\BlogManager\\Model\\BlogFactory $blogFactory\n     * @param Session $customerSession\n     * @param \\Magento\\Framework\\Serialize\\Serializer\\Json $jsonData\n     *\/\n    public function __construct(\n        Context $context,\n        \\Webkul\\BlogManager\\Model\\BlogFactory $blogFactory,\n        Session $customerSession,\n        \\Magento\\Framework\\Serialize\\Serializer\\Json $jsonData\n    ) {\n        $this-&gt;blogFactory = $blogFactory;\n        $this-&gt;customerSession = $customerSession;\n        $this-&gt;jsonData = $jsonData;\n        parent::__construct($context);\n    }\n\n    \/**\n     * Provides content\n     *\n     * @return Magento\\Framework\\Controller\\Result\\Redirect\n     *\/\n    public function execute()\n    {\n        $blogId = $this-&gt;getRequest()-&gt;getParam(&#039;id&#039;);\n        $customerId = $this-&gt;customerSession-&gt;getCustomerId();\n        $isAuthorised = $this-&gt;blogFactory-&gt;create()\n                                    -&gt;getCollection()\n                                    -&gt;addFieldToFilter(&#039;user_id&#039;, $customerId)\n                                    -&gt;addFieldToFilter(&#039;entity_id&#039;, $blogId)\n                                    -&gt;getSize();\n        if (!$isAuthorised) {\n            $msg=__(&#039;You are not authorised to delete this blog.&#039;);\n            $success=0;\n        } else {\n            $model = $this-&gt;blogFactory-&gt;create()-&gt;load($blogId);\n            $model-&gt;delete();\n            $msg=__(&#039;You have successfully deleted the blog.&#039;);\n            $success=1;\n        }     \n        $this-&gt;getResponse()-&gt;setHeader(&#039;Content-type&#039;, &#039;application\/javascript&#039;);\n        $this-&gt;getResponse()-&gt;setBody(\n            $this-&gt;jsonData-&gt;serialize(\n                    &#091;\n                        &#039;success&#039; =&gt; $success,\n                        &#039;message&#039; =&gt; $msg\n                    ]\n                ));\n    }\n}<\/pre>\n\n\n\n<p>This code is pretty self-explanatory. Instead of redirecting we have returned <a href=\"https:\/\/webkul.com\/blog\/generate-json-data-and-convert-in-pageblocktable\/\">JSON data<\/a> to our ajax request. Here we are returning two variables, success flag, and message. <\/p>\n\n\n\n<p>We have also removed the message manager&#8217;s message because those message gets displayed only when the page reloads.<\/p>\n\n\n\n<p>Now if you load the blog list page and click on the delete button. You should see similar results as below &#8211;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"800\" height=\"396\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/ezgif.com-gif-maker.gif\" alt=\"ezgif.com-gif-maker\" class=\"wp-image-283816\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>For some of you, the static files i.e. css and js files might not get updated even after cache flush. That&#8217;s because Magento stores the static files inside the &#8220;pub\/static&#8221; folder. <\/p>\n\n\n\n<p>To regenerate these static files we need to run the static content deployment command,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">php bin\/magento setup:static-content:deploy -f<\/pre>\n\n\n\n<p>And in some extreme cases, we need to delete the contents of the <em>pub\/static<\/em> folder before running this command. Just make sure that you do not delete the <em>pub\/static<\/em>\/<em>.htaccess<\/em> file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JS widgets :<\/h2>\n\n\n\n<p>Now let&#8217;s add a confirmation widget so that our bloggers do not delete the blogs accidentally. Also, we will add an alert widget to let users know that the blog was deleted successfully. <\/p>\n\n\n\n<p>We will use the Magento versions of these widgets. Magento provides many widgets but we mostly use alert, confirm, and modal widgets.<\/p>\n\n\n\n<p>Let&#8217;s edit the js file <em>view\/frontend\/web\/js\/bloglist.js<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/frontend\/web\/js\/bloglist.js<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">define(&#091;\n    &quot;jquery&quot;,\n    &#039;Magento_Ui\/js\/modal\/confirm&#039;,\n    &#039;Magento_Ui\/js\/modal\/alert&#039;,\n    &#039;mage\/translate&#039;\n], function ($, confirmation, alert, $t) {\n    $(&#039;.blog-list-table .blog-list-table-action.blog-list-table-action-delete a&#039;).on(&#039;click&#039;, function(e){\n        var self=this;\n        e.preventDefault();\n        confirmation({\n            title: $t(&#039;Delete?&#039;),\n            content: $t(&#039;Are you sure you want to delete this blog?&#039;),\n            actions: {\n                confirm: function(){\n\n                    \/\/If confirmed\n                    var url = $(self).attr(&#039;href&#039;);\n                    $.ajax({\n                        type: &quot;GET&quot;,\n                        dataType: &quot;json&quot;,\n                        url: url,\n                        data: {},\n                        beforeSend: function() {\n                            $(&#039;body&#039;).trigger(&quot;processStart&quot;);\n                        },\n                        success: function (response) {\n                            $(&#039;body&#039;).trigger(&quot;processStop&quot;);\n                            $(self).closest(&#039;.blog-list-table-row&#039;).remove();\n                            alert({\n                                content: response.message\n                            });\n                        },\n                        error: function (response) {\n                            $(&#039;body&#039;).trigger(&quot;processStop&quot;);\n                            alert({\n                                content: $t(&#039;Something went wrong.&#039;)\n                            });\n                        }\n                    })\n                    \n                }\n            }\n        });\n    })\n});<\/pre>\n\n\n\n<p>Please notice the changes from the last version of this file. We have requested alert and confirm widgets in <em>define<\/em>. Please check out their syntax in the Magento devdoc. <\/p>\n\n\n\n<p>Basically, the confirm function inside the action will get executed when the user clicks on the OK button of the confirm widget. So we have written all the ajax code in that block. <\/p>\n\n\n\n<p>We have also used the alert widget in the success and error section of the ajax request to show the message from the server and an error message respectively. <\/p>\n\n\n\n<p>This alert is not the same as the javascript&#8217;s alert message.<\/p>\n\n\n\n<p>We have also used the translation library with <strong>$t<\/strong> to make the static content translatable.<\/p>\n\n\n\n<p>Now if you try to delete you should get a similar UI as below,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"800\" height=\"396\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/ezgif.com-gif-maker-1.gif\" alt=\"ezgif.com-gif-maker-1\" class=\"wp-image-283819\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>The folder structure should look like this,<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"413\" height=\"707\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_115.png\" alt=\"Selection_115\" class=\"wp-image-390902\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_115.png 413w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_115-175x300.png 175w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_115-145x249.png 145w\" sizes=\"(max-width: 413px) 100vw, 413px\" loading=\"lazy\" \/><figcaption class=\"wp-element-caption\">Folder Structure<\/figcaption><\/figure>\n\n\n\n<p>Next Blog -&gt; <a href=\"https:\/\/webkul.com\/blog\/create-admin-menu-and-controller-in-magento-2\/\">Magento 2 Development 15: Admin Menu and Controller<\/a><\/p>\n\n\n\n<p>Previous Blog -&gt; <a href=\"https:\/\/webkul.com\/blog\/delete-action-column-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">H<\/a><a href=\"https:\/\/webkul.com\/blog\/magento-development-10-deleting\/\" target=\"_blank\" rel=\"noreferrer noopener\">ow To Add Delete Action Column In Magento 2<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Magento 2, integrating CSS and JavaScript involves several steps. Here\u2019s a comprehensive guide to help you with the process: CSS : Let&#8217;s first start with styling our pages. We will add styling to the add and edit page. But before that let&#8217;s add some div blocks and classes in our phtml files so that <a href=\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":201,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[2070],"class_list":["post-283289","post","type-post","status-publish","format-standard","hentry","category-magento-2","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Use CSS and JS in Magento 2<\/title>\n<meta name=\"description\" content=\"How to Use CSS and JS in Magento 2 - In Magento 2, integrating CSS and JavaScript involves several steps. Here\u2019s a comprehensive..\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use CSS and JS in Magento 2\" \/>\n<meta property=\"og:description\" content=\"How to Use CSS and JS in Magento 2 - In Magento 2, integrating CSS and JavaScript involves several steps. Here\u2019s a comprehensive..\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-25T15:19:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-28T10:41:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-1200x581.png\" \/>\n<meta name=\"author\" content=\"Sanjay Chouhan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sanjay Chouhan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/\"},\"author\":{\"name\":\"Sanjay Chouhan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\"},\"headline\":\"How to Use CSS and JS in Magento 2\",\"datePublished\":\"2021-02-25T15:19:44+00:00\",\"dateModified\":\"2025-05-28T10:41:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/\"},\"wordCount\":1276,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-1200x581.png\",\"keywords\":[\"Magento2\"],\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/\",\"name\":\"How to Use CSS and JS in Magento 2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-1200x581.png\",\"datePublished\":\"2021-02-25T15:19:44+00:00\",\"dateModified\":\"2025-05-28T10:41:15+00:00\",\"description\":\"How to Use CSS and JS in Magento 2 - In Magento 2, integrating CSS and JavaScript involves several steps. Here\u2019s a comprehensive..\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25.png\",\"width\":1647,\"height\":798,\"caption\":\"2021-02-24_19-25\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Use CSS and JS in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\",\"name\":\"Sanjay Chouhan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Sanjay Chouhan\"},\"sameAs\":[\"https:\/\/www.instagram.com\/sanjaychouhansc\/\",\"https:\/\/in.linkedin.com\/in\/scchouhansanjay\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Use CSS and JS in Magento 2","description":"How to Use CSS and JS in Magento 2 - In Magento 2, integrating CSS and JavaScript involves several steps. Here\u2019s a comprehensive..","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"How to Use CSS and JS in Magento 2","og_description":"How to Use CSS and JS in Magento 2 - In Magento 2, integrating CSS and JavaScript involves several steps. Here\u2019s a comprehensive..","og_url":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2021-02-25T15:19:44+00:00","article_modified_time":"2025-05-28T10:41:15+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-1200x581.png","type":"","width":"","height":""}],"author":"Sanjay Chouhan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sanjay Chouhan","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/"},"author":{"name":"Sanjay Chouhan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462"},"headline":"How to Use CSS and JS in Magento 2","datePublished":"2021-02-25T15:19:44+00:00","dateModified":"2025-05-28T10:41:15+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/"},"wordCount":1276,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-1200x581.png","keywords":["Magento2"],"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/","url":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/","name":"How to Use CSS and JS in Magento 2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25-1200x581.png","datePublished":"2021-02-25T15:19:44+00:00","dateModified":"2025-05-28T10:41:15+00:00","description":"How to Use CSS and JS in Magento 2 - In Magento 2, integrating CSS and JavaScript involves several steps. Here\u2019s a comprehensive..","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/02\/2021-02-24_19-25.png","width":1647,"height":798,"caption":"2021-02-24_19-25"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/use-of-css-and-js-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Use CSS and JS in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462","name":"Sanjay Chouhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Sanjay Chouhan"},"sameAs":["https:\/\/www.instagram.com\/sanjaychouhansc\/","https:\/\/in.linkedin.com\/in\/scchouhansanjay"],"url":"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/283289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/201"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=283289"}],"version-history":[{"count":26,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/283289\/revisions"}],"predecessor-version":[{"id":493912,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/283289\/revisions\/493912"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=283289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=283289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=283289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}