 Welcome back to the channel. In our previous video where we were developing native Gutenberg blocks, we were able to create this block and we are able to change the alignment and so on and we can be able to add other native features that are in the block editor. Now there is one particular concept that I want to expound on and that is basically using static and dynamic blocks. Now what are these? What are dynamic blocks? What are static blocks in their very nature? So right now I'm going to open up two different instances of a dynamic block and a static block and we can start comparing them so that you understand which one is the best for your particular use case. Sometimes you can find that using a dynamic block makes more sense, other times having a static block is the best way to go. So if you want to see that then jump with me in the code. So the first thing that I'm going to do is go back to my plugin section and I'm going to disable this particular block so that we don't have it showing up. Disable all these other blocks as well because we don't need them. And then in here I'm going to open up my integrated terminal and in here I'm going to use npx which is basically an npm command but this one allows you to install only what you need and note into your system and I'm going to go for the wordpress slash create dash block and if I hit enter on this so you will see that it will start asking me questions and I can feel in whether I want a dynamic or a static block. Now what I'm going to do is stop running of this command. I'm going to do something different where I say static block plugin is going to be the name of our plugin and I'm going to add dash dash variant which is a command line variable that we can change and say we want to have a static block. So when we hit that wordpress will start scaffolding for us this new plugin and when we open it we're going to see that all the files that we need are starting to be added. I'm going to open another terminal window and I'm going to do the same thing. So instead of using the static variant I'm going to use the dynamic variant and I'm going to change this from static to dynamic block plugin. I'll hit enter and since these are two different things they're all going to install at two different times but that will allow me to serve on time. So I'm going to split this so that I can see this and then I can be able to also see what's going on here. We can see that my static block is installing as well as my dynamic block at the same time and we see we have these two here. We'll wait for them to just complete installing. Now you can see that all our plugins have finished installing. Our static which was here has actually finished installing as well as our dynamic one. So we have this here. Now I'm going to compare those two by just looking at the file structure. You'll see that in these cases both we have the name of the file that kicks off the process. We have package.json, iridmi, gitignoredita.config We have the node modules, a source and a build. So we're going to go into the source folder because that's where we usually have the differences. We have a block.json in both instances. We have an edit.js which is the same. We have editor.css, index.js and then we have a render.php here which is not here. And when we look at this we have a save.js which is not here. So those are the two files that are not available in this case. Now if I was to look inside this file the save.js you'll see that they tell us that this is the particular file that allows us to have the final markup which is serialized and then used in the post content area. Now if we look at the render.php you're going to see that it actually has some php in it and then you can actually have content that is in there. That is one of the biggest differences in that with the dynamic block we have a render.php so it allows us to do php stuff or server-side stuff in php basically you could even have like a debt for example so if I was to add some php here and say okay let's echo and we're going to have debt and we want to have the debt as a ya we can be able to save this and you're going to be able to see this. So I'm going to add a dash and then we'll be able to see this change. Now I'm going to go back into my plugin section and reload and I'm going to load both. I'm going to load my dynamic block and my static block and when I go to pages go to the sample page I'm going to just take out this block that is broken and down here I'm going to say so we'll just have a static block which we shall say this is slash static block plugin and then after doing that we're going to have a dynamic block below it so slash dynamic block plugin I'll hit save here and then I'm going to go to preview the pages so you will see that here we have the static block showing this and the dynamic block showing us what we have here now I want to make a few modifications to this particular block so I'm going to erase this and I'm going to leave this path that says you know what let's echo the debt and we want to get the ya so I'm going to save this I'll come back here and I'll reload now you're not going to see a change simply because I have not compiled our new changes in here so what I'm going to do here is I'm going to open up this in the integrated terminal and I'm going to hit npm run build which is a function that's already in my package.json so basically it's just going to rebuild this package if I reload now you'll see that it shows our year which is 2023 and if I want to make more changes to this I can do anything in PHP now you realize I didn't have to go back into my editor and fix this particular block and change anything about it everything was done on the server side and this is actually showing up now with our static block there is a bit of a difference so if I want to change what we have inside our static block I'll have to go to rsafe.js and then say change this I'm going to run this also in the editor I'm going to say npm run build hit enter and if I reload you're going to see that this actually breaks the block in comparison to the dynamic which is not broken in as much as we change them and that is simply because WordPress does not know how to deal with this particular block it has changed in its structure and so WordPress needs to know how this was deprecated and how to handle the HTML and that is simply because when I go to the editor here the way the static block is handled all the information is actually saved it's actually saved as information in here and then also saved in our database now because of this little change that we've done here and say change WordPress cannot understand because it only knows this that doesn't have a change so I'm going to go back so in this particular case I'll have to remove this come back and then say let's add our static block and then once I hit save and update we're able to see that this actually changed and in here it's not breaking so static blocks are most likely going to break in comparison to the dynamic blocks and that is simply because any change that you do in the markup on the static block needs to be reflected in the database and also WordPress needs to know how to handle it so you need to know how to do deprecations and that's a thing we shall see in the future I'll make a video about how to make a deprecation for your static block so these two files being different is the biggest difference inside handling static blocks and dynamic blocks so if you want to convert a short code that you had with PHP previously I would advise you to use a dynamic block so that you can reuse some of that code if you want to but go ahead you can try to make it a static block because with all the elements that you get from JavaScript you're able to handle reactive differences for example when someone changes one small thing here the change is visible to their eye in that very instance so you have that reactive nature of JavaScript helping you in the behavioral layer so that's the biggest difference with the dynamic and the static blocks now the other difference that you will see with the static block is that when you go to the block.json you're actually going to see that down here you only enqueue the editor script you enqueue the editor style and then you add the style as well but with the dynamic block you actually have all those coming up the editor script editor style the style and then you have the render file also being enqueued right here otherwise all the other things remain the same and you're able to do with them as much as you want so the things that happen in the editor.js are actually going to show up in the backend when someone is editing so if you want your user to see the changes happening in your backend you'll be able to do those changes in both instances because both files actually have an editor.js whether it's static or whether it is actually dynamic the purpose of the editor.js in both cases is so that we can add controls and different items that allow us to manipulate our block and we'll see those on the backend it is important that we make all our changes while on the backend but then also do not distort the front end which is in the save.js if we are to make changes to the html that's going to be passed in the save.js we then need to have deprecations added to our particular block plugin otherwise we end up breaking the block this is the big issue for the static blocks and yet for the dynamic ones we're going to be using PHP to render out our output so we're not going to be having the front end breaking just because we made changes to the backend now remember the choice is yours if you're going to make something that renders the output using PHP then go ahead use the dynamic block now if you enjoy the video or if I confused you a little bit please let me know in the comment section don't forget to give this a thumbs up if it was clear enough for you share with a friend the video and also leave a like now if you want to see me convert a short code into a modern day block I'll be doing that in a video that is coming soon so make sure you hit your notification bell so that you don't miss out otherwise enjoy whatever you're developing