Everyone misplaces things from time to time. Keys, AirPods, sunglasses, wallets, anger, confidence, sense of entitlement. JavaScript in Power Pages is no exception. I know there is a script. I can see that annoying debugger keyword. I just have no idea where the f*** did it come from. In this episode of Refresh the Cache, Nick and I discuss all the possible locations where the script can be hidden in Power Pages, while contemplating using Dropbox as a source control alternative. And remember, we never truly lose any material possessions. We only temporarily misplace them.
Good afternoon. I'm George Lubinsky. And I'm Nicholas Hadouk. And today we are here in our little studios to talk about hunting for Red October or where the f*** do you put that script? Oh, where the beep do you put that script?
the JavaScript or TypeScript. Do you do any TypeScript in JavaScript development, in portal development, pages, pages development? Absolutely. Lots of React stuff. That's usually when we kind of bring in the TypeScript is when we're doing kind of React components, dropping them into PowerPages. So yeah, that adds a whole another level of fun trying to compile your TypeScript so that it ends up... How often do you bring React?
That's kind of new things to do things, but how often it happens? Relatively often, like especially on the larger projects when these days with the PCF controls, like you might kind of go down that road and you kind of drop a PCF control in the same way that you could just drop a React component. But yeah, we've built quite a few PowerPages sites where they... They just have an experience that has to be almost completely custom developed in a certain area. And, you know, we kind of shy away from doing any of that complex stuff and kind of old school jQuery, anything like that. So we bring in React when it's anything more than just kind of interacting with forms and, you know, simple validation, that sort of thing that we stick with kind of old school jQuery. If we're doing any sort of kind of custom UI, it's usually in React these days. Interesting. Interesting. So we yet to talk about marketing implementation, which was Angular, or still is. I wonder what's going to happen to that. But I think we did talk about it.
Probably there were a couple of guys who knew Angular inside out. They decided to do it in Angular. So these days it's probably React would be the first choice. Yeah, I continue to refuse to discuss anything related to the marketing portal. Okay, then you'll be silent on the next podcast episode when we do talk about marketing implementation. But back to that script, regardless whether it's JavaScript or TypeScript.
TypeScript, well, basically it's transpiled to JavaScript. So you end up with some script that you need to bring into your environment. And then that script will do some magic, presumably swaying users and knocking them off their feet and saying, this is brilliant. This is the best thing ever. Let's go through locations. Like there's multiple places where you can put JavaScript in portals. So let's go through them one by one and see what are the pros and cons. What would be your first choice where to put JavaScript? And don't tell me it depends. So I think the number one best advice is consistency.
Honestly, like any of the options we're talking about, none of them are awful. There's a reason why, you know, those different places were created and they kind of have their purpose. But it's really about understanding what the options are and just being consistent on a project. We're brought in quite a bit to kind of review other people's portals, provide advice on what to do. And I think that's the number one thing is people, when we say, you know, where the bleep is my JavaScript, the biggest problem is, well, in some cases, it's in a web template that's included in page content. And then in other cases, in a content snippet, it's like, there's just, there's way too many options. So traditionally, I'd say the vast majority of JavaScript that you're going to see is on a list or a form. That's where we see a lot of the JavaScript. And so with those ones, those tables, so whether we're talking about forms or lists or multi-step forms,
They do have a specific kind of custom JavaScript area. And I do kind of prefer to use those as much as possible. And the reason I like those is that that form or that list could be used on multiple pages. If you put it in that form or if you put it in that list. no matter where you put that form, that's going to happen. The times when I often will put it into the page is when, for whatever reason, if you have a form that's used multiple places, sometimes that page or that form needs to react differently per page. So then that's kind of where it makes sense to, you know, put it on the page. So really I look at it as there's kind of all these layers. You start off with like the header and footer, then you kind of have the page and then you have the page template, the page, and then you have the forms list. So I like to kind of go down as far down that rabbit hole as possible because it really just usually promotes kind of reusability and containment and all that sort of thing. So that's where I like to do it. I don't have a good reason for why I don't do a lot of, you know, you could basically put everything in a way.
template and then start using the liquid includes to kind of include it and also that's not probably a bad strategy i don't know why i just it's never been the way that i've approached it i usually just kind of put things directly in there except of course if we have something that we want to reuse over and over and over again so a javascript or sorry liquid include is a good way to do that is if you put in a web template um to do that my only beef with that is you bloat in the page uh if you include within template you deny browser um any choice of caching. You just bloat in your page. Your page, it is what it is. Browser is unable to request multiple files in parallel. Like if you decide to include all the images in line, is it going to work? Yeah, sure. Is that a good idea? No, because you're just requesting everything in one request that cannot run in parallel. You have to wait until everything is loaded. The advantage is that you probably control the timing of things a little bit better. There was a JavaScript library to guarantee the order in which other libraries are loaded. The name escapes me. The Required JS? Required, yes. Required JS. But to me, if you go to that depth within the...
PowerPages or PowerApps portals, you're trying too hard. This is not what portals are about. Just go and knock your own React site and do whatever you want to do and talk to Dataverse at the back end in your own code rather than try to reuse portals foundation because that's not what portals are about. To me, it's about flexibility and fast development rather than trying to mold portals into something that they're not. Let's kind of list the places. You mentioned them all, but just for the listener's sake.
Let's list them one by one. So forms, lists, or multi-step forms. So if you want to have your script to deal with specifics of a form or a list, then that's where you put it. Because then it becomes reusable. Wherever you put that form or list, your script travels. The other place is to put into page content. That becomes page-specific, but then you can customize this. And one of the reasons I've seen probably once or twice is multilingual. When your script varies between languages, then you can actually put a different script.
You really need to parameterize and things like that. But if you're under pressure, then you can put different script. And I've seen it. Actually, the example I saw was from Canada. If French do this, if English do that. And that was a perfect example. Very similar script. Just under pressure, hot-coded some of the names. One of the things you do have to watch out for is the rich text editor that you'll see kind of in the back end. Sometimes that can do some funky things with script takes and that sort of thing. So if you're kind of exclusively in, say, VS Code or you're exclusively in the portal code editor, you're not going to run into problems. But we have seen where script does funny things as soon as people started loading it up in the portal management app.
Oh, I can't tell you how many times I lost, let's say, minutes. I'll be very conservative. Minutes of work. When I open my page, and there's nothing in editor, and then autosave kicks in, and there's nothing in Dataverse. And then I have to go and recover that code from elsewhere and, you know, from UAT side or whatever, if we have one on that particular project. The other place to put the script is on the web page record. There is a place in there for JavaScript, custom JavaScript, right? Yep. This is not page content. So to differentiate between the two page content is you literally go into page content and just put the, you know, script tags and put the script in. And that's when that mess happens because sometimes reach tech editors say,
Oh, you put in a tag in. No, I don't want to see no tags. Boom, out of the window. So we've seen it with fetch XML. We've seen it with script. But there is a place to put custom JavaScript on a web page record. Just very explicitly, you put it as part of... I'm not sure where does it go when the code actually spits it out, the entire page. Is it before the content, after the content? I think it might be after the content. After the content. And that one I do believe, because that one you specify. So that's one of those kind of weird things with the multilingual model, where you have the root web page, and then you have all the localized pages, and you're never sure.
Okay, there's actually a custom JavaScript on all of those, right? But I would say I'm 99% sure that it's actually pulling from the localized version. So you could use that to get your kind of multilingual support there as well. That's a good place. To me, that's a good place to do some funky stuff with a specific page. Because then it travels between the languages and it's kind of consistent. You can refer, you know what's on page. You can refer to blocks and bits. We used it in the past, something like to generate, for example, user-friendly assistance control, like helpful controls that you hover and it appears like help, you know, yellow.
ish help blocks and like inline help that is stored elsewhere, but appears as part of the page. Not sure, what did you use localized content? Yeah, so on the custom JavaScript, we'll use it if, and this is relatively rare, but when you have a single form that you use on multiple pages and for whatever reason, often it's when there's like an anonymous version and a logged in version. And for whatever reason, the validation is different. You just need a little bit of different JavaScript. So in that case, it doesn't always make sense to put the form or the JavaScript on the form. So that's when you can have stuff that's kind of more specific to that particular page in the custom JavaScript.
And now we're coming to kind of a little bit more interesting scenarios where you can put, in theory, in code snippets. I don't recall that I ever done that. Have you? No, I don't think so. I think sometimes I've seen content authors attempt to do that when they're kind of working in and they say, oh, I can put some JavaScript in there. But yeah, I mean, if you have an HTML-type content snippet, in theory, you could put it there.
Why would you want to do that? Well, I think the one case I can think of is not the tracking code, a content snippet. So where you put your Google Analytics or your Application Insights code. Oh, that's interesting. But wouldn't you want it like in the footer or something?
Right, but they do, I think it's a content snippet that's kind of automatically included in the page template, which does kind of put it down. Oh, I see. Yeah, there is a content snippet that actually spits out the tracking code for analytics. Yeah, so there's like that special place in the model driven app where you can go and like set the tracking code, but all it's doing is setting a content, I think it's a content snippet. And so yeah, you copy in your Google Analytics or your application insights, which is technically some scripts. But again, you still have to include your script tags in there. So it's like kind of the difference between the page content where you do have to include the script tags, whereas the custom JavaScript is already wrapped in those script tags for you. If you put in more script tags, bad things will happen.
Which kind of brings the next one, which is web templates? That's kind of a bit more advanced version of the same code snippets. You just bring the web template and your web template can include script or it could be script in itself or it can do multiple things. It can bring external script. It can generate script. This is where we start talking about script and liquid. When we were talking about the subject just before this recording, you were...
Quite excited. That's one of the powerful things you can do. Tell a bit more about that. Yeah, for people who are kind of either new to server-side or client-side programming, it's the mixing of JavaScript and Liquid, which can be a little bit challenging because Liquid is a server-side language. So it runs on the server, it generates some code, and then you have your JavaScript, which is a client-side language that runs in the browser. So just trying to kind of just work out in your brain, you write this mix of Liquid and JavaScript, you have to understand that kind of one runs first, generates other code.
that then is run in the browser. So we'll often use that when we're saying we want a list of things. So we'll use Liquid and fetch XML to grab stuff from Dataverse. And maybe we'll output that as a JSON array that then the JavaScript can consume. So that's a pretty common technique. And I think that there's some really super powerful things you can do if you just mix those two together. But if you're not kind of comfortable with understanding how server-side and client-side all plays together, that it can be a bit challenging at first. But then to confuse developers even further, your JavaScript, which is client-side language, can call...
a page, which is nothing more but JavaScript served by a web template, which it runs on the server. So yeah, it's really once you start understanding that Liquid runs on the server, JavaScript runs on the client, and they can interchangeably, almost interchangeably call each other. Liquid can generate JavaScript. JavaScript can call into Liquid indirectly by a web template. So that's where, to me, that's where the power is and flexibility. Sometimes it's too much. When flexibility falls into the wrong hands, then we end up with, you know, hunting for that JavaScript.
you know there is a piece of JavaScript, you know it's running, and you just don't know where it is and who put it there. Well, we did miss one location, not miss, but skip one location, and that's external, when you have external libraries. Yeah, and whether those are served off a CDN, like jQuery or the Bootstrap JavaScript, or if you've decided that for whatever reason on your project, that's how you want to deliver your JavaScript, so you throw it up on Azure Blob Storage or whatever, and you just refer to it in a script tag, I've seen people do that, for sure. With portals using CDN now, or pages having an explicit switch, does it make sense to actually roll out your own CDN? I've seen some people do it from an ALM perspective. They were just more comfortable with distributing their library, as well as some partners will, if they have some code that they use on every single project, they just have one version that they can put out there, and then all of their different portals can access that one via CDN. So I think there are some use cases, but I wouldn't say it's super common. Which brings to the next topic, source control. With all those one, two, three, six places where you can place JavaScript, how do you source control those things? I'm not really a big believer in source control. I mean, if you're doing it properly, then you should have no reason to ever go back to source control, right?
Oh, I use Dropbox. Dropbox has history. Yeah, exactly. Exactly. And we turn on the auditing feature in Dataverse so we can just go back to see all of our changes. I find that's the easiest to work with.
If only that was true. So in terms of source control, I mean, that'll get kind of tied into the whole ALM process. And there's still, I get asked this question, it seems like every single day, how do you deal with the ALM process? We are still kind of stuck in the world of the configuration migration tool. That's kind of our preferred right now. But whether you're using the configuration migration tool or the portal configuration mover or the PAC CLI to export your stuff, I mean, that's really what it is. We export that whole entire piece and that includes all your JavaScript. When we use the configuration migration tool, what you get is a zip file.
um that zip file doesn't look very nice when you check into source control so we unzip the file but not only do we unzip the file because we want to do pull requests on all of our javascript we actually have our own kind of custom powershell scripts that go through the unzipped xml and actually extract out you know, all the things we've talked about where there's actual code. And then we extract those out into another file so that in our source control, we actually have the individual JavaScript and HTML files that we want to be able to see. Because otherwise, in the configuration migration tool, because it's all XML, you get this encoded gobbledygook that you would never want to look at. So that's kind of how we handle it is we do our exports using the configuration migration tool. We have our scripts that kind of unpack it and turn it into some nice JavaScript. And that's what we kind of pull requests and use to kind of confirm and have it on source control. Okay, it wouldn't be better, following that logic, better to actually have the script organized nicely in either web templates,
or external files or web files, which we're going to talk about in a second, organize it there as JavaScript, not as part of a page as JavaScript, and then reduce your, say, page script to a simple include or external reference. Then you avoid the whole step of decoding gobbledygook and converting it to JavaScript and things like that. I know it's less convenient, but... Even in web templates, it's still gobbledygook because it's still like the ADX underscore value or whatever it is. So even in the web templates, that thing is gobbledygook. It would kind of save you from having to identify all the different locations where we do want to decode it.
But I guess just because of how we've been doing it, we just kind of went through the process of identifying the, I don't know, 10 different places where... So unless it's external file, you say nothing you can do because it's part of the data record or data row. Sorry, it should be called row now. Still having difficulties. You know, I got used to tables and columns as opposed to entities and fields. I'm still having mental block on records versus rows. You put...
columns on your rows and when you're talking about fields on the form. That's where I struggle. I put my columns on the forms. I'm okay with the row. Like, oh, you create a new row, I get that. But yeah, adding columns to a form, every time I have to type that, I cringe. So speaking of different types, as I mentioned, you can do different kind of style of JavaScripting, like, oh, TypeScripting, for that matter. So you can do inline. You can do as a web file. That is, you've got the web file, .js, except don't forget to rename it before uploading, because otherwise you end up with...
Nothing. By default, portals block .js files from being uploaded. They also block executables and a bunch of other files, safety feature. So you have to rename, pretend it's JavaScript, and then say, please serve me a JavaScript. So there's a name, there's a content of the file. When you upload content, you have to rename it. So if any of you listeners, you wonder why your JavaScript just wouldn't go as a file, that would be the reason. Yeah, we usually just turn that setting off for a moment as we upload because there's things like the XRM Toolbox Portal Code Editor. How long is your moment? Is it enough for me to sneak in? It would be long enough for you to sneak in, but not most other people.
Okay. I'm small and I'm going to sneak in. So then there are web templates to be included in another web template. You just include. And to me, a huge advantage of web templates is ability to include parameters. So you can actually change your JavaScript or whatever content of your web template be driven by parameters. Like authenticated versus unauthenticated. The same script can be served by the same template, except include a switch on or off. Unauthenticated. Probably not the best example, judging by your face. Like very skeptical. No, no. So the other place where we usually include...
and this also makes me cringe, but it was one of those, hey, we just have to make it work is a page of content that literally was pages and like thousands and thousands of line. And we basically reached the maximum number of characters that you could fit in one of those fields. So whether it's the page content or the custom JavaScript or any of those fields. So one way to get around that is just create multiple web templates and then just include those. So just something, if you ever run into it and you're, and you don't want to, it's a quick way to win that fight. It may not be the prettiest way, but it's a quick way.
Okay. The one that seems to surprise you a bit earlier today is to actually use web template to deliver text JavaScript the same way as you deliver data or JSON web services. You can do JavaScript the same way. So you do a template, which is JavaScript. You set the type to text JavaScript, and then you have a web page that serves that content. So you just call another page. It may not end up in JS, but who cares, right? Yeah, so you have a web page which uses a page template, which is a web template type web page template, which then references that web template. And again, yeah, we do that all the time to create our kind of little mini JSON services, but I'd never use that for just, you know, here's a bunch of JavaScript. So that's a great idea. To me, that lends itself well for Cation. So if you've got massive script that you want to be like served once and forget about it, that would be a good technique because that's static and that's just reference to a file. Easy to edit.
So you can easily go and tweak it. And at the same time, it's great in performance. And then the last one is, again, external JS reference. And you did flag web files and external JS references. Yeah, so those ones, we talked about mixing liquid and JavaScript. But unfortunately, with either of those two techniques, they're not going to evaluate any liquid that you would have. So putting our own custom JavaScript in a web file, we generally avoid it because of what you just mentioned earlier, but it's just kind of a pain to deal with. But there was always kind of that downside that caching is not as effective because it's all just kind of in line. So I'm very much liking this web template to deliver JavaScript. That kind of solves both worlds. But yeah, using an external JavaScript reference, it just kind of goes back to what we talked about earlier that
Yes, it's good for caching. And if it's kind of getting reused in a bunch of different places, that's going to be an effective way to handle it as well. Which actually brings me to an interesting topic. With the web templates and Liquid, you can generate JavaScript on the fly. And the content of your JavaScript that you generate can and will vary. For example, you can generate JavaScript that is based on choice or option sets, values. You literally can generate insert options and just inject options on the fly, retrieve it from database, from that choice field, or from that choice.
Caching, how does that work with being very efficient? Is caching is disabled or client-side will blindly cache it and you need to kind of add your own timestamp at the end to stop client-side from caching the script that you generate? Or does the system where you include liquid, is it smart enough to say, hey, please don't cache me ever? I think that your technique of doing a web template to deliver JavaScript caching might be a problem there because the actual JavaScript page might be smart enough to realize that this is a different user, but I don't think the browser would be smart enough to kind of pull a new version. So that would be one of the challenges that if your page did need to kind of change based on who the user was. And so like the caching of things like JavaScript, sorry, of Liquid, it will be generally handled by, you know, if you have different users, the one kind of big exception to that would be within the header and footer. If you have the output caching turned on, that can be.
That's not necessarily going to take into account users unless you start using some of the donut caching. But I think if you use that JavaScript technique. of trying to deliver your JavaScript with a web template, I think your browser is not going to realize that that stuff changes per user. And so you might just have to, it's a pretty easy solve by just including a query string parameter. You could put the, you know, the ID of the current contact as a creation parameter, and that's going to trick the browser into doing that. But it's something that you have to, you have to consider. And someone had registered for my portals community call the other day and was basically saying, hey, how do I deal with caching in just kind of in general? And like, how do they expect people who are doing kind of low code, no code stuff to deal with this? Like, there must be a better way. And the answer is, unfortunately, there isn't. Fortunately, there isn't, because that's foundation of performance internet.
Yeah, I mean, it would be nice to, you know, there's certainly some places where strategically if we could clear the cache using some mechanism. Of course, if it was abused, it would be very bad, but I think... I still think that that's a feature that needs to show up a way for us to strategically, you know, you have Power Automate flows that are running in the background. There's got to be a way for us. I feel like it's just, it's too necessary for them to forever say, no, we're too worried that people will abuse that. There's got to be something they can put in place so it doesn't get abused. But I think in the long term, that's a bit of functionality that we need is to be able to invalidate. Solve this development puzzle and we'll give you a key to access cache. Yeah, something like that. That would be nice. So with this cache, the technique used substitution and substitution. Does that help?
Oh, is that the download caching that you referred to? That's in the header and footer. So that's basically to exclude that. Oh, are you saying it's not going to work inside the standard page? I don't think so. I think that only has to do with the output caching, which is only in the header and footer. That's a nice piece of knowledge to have. Here you have it. I didn't know. I honestly didn't know that substitution is not going to fly within the page content. Which brings topic in general, like caching, dynamic data, parameters, how you develop, how you debug, how you step through your JavaScript. What do you do? It really kind of depends on the complexity of the project. Like I mentioned earlier, in some cases, we do have entire React apps that we're building. So I like using Fiddler.
to do the, I think they call it the autoresponder or whatever. Autoresponder. It's documented technique. You can go and find it. It's documented. I'll put a reference in the show notes. But essentially the idea is there is that you have your file. And so just tying this back to like where you're going to put your file, if you, this would be where you do want it to be in some sort of like addressable, like, hey, here's my particular file, whether that's in a web file or whether that's in, you're using your technique of it being on a page, but you do want it to be like, here's a file. And then what you can do is you can tell the, you can use Fiddler to say, hey, when you actually request that particular URL, don't actually go to the web, pull it from this file locally on my machine. And so then you can just edit the file.
locally on your machine. And that's quicker mainly because of our favorite friend, which is caching. So rather than making your update in Dataverse, waiting for the cache to clear or clicking the browse website button, it's immediately updated because the browser's not even actually going back to the website. It's just pulling locally from your machine. So I do that on projects where I'm going to be in there for days or weeks at a time. For littler projects where it's like, hey, can you help me with this bit of JavaScript, I'm typically using still the XRM Toolbox Portal Code Editor.
making my quick changes. I find that way easier to use and to browse through all the different files. You know, if we're doing an analysis of a particular portal that we may not have built ourselves, again, Portal Code Editor makes it easy to kind of browse through everything. The VS Code, the PAC CLI, is also a great way to do that. I just, again, it's not a habit that I've gotten into yet. But again, those are my kind of two main techniques is I'll literally have things open in VS Code and using Fiddler to use the autoresponder to replace them. Or I'm debugging in, or I'm putting my code into the portal code editor in the XRAM toolbox. And I've got one tab open. That's my clear the cache button. And then I've got my main page open for development. So I make my change in XRAM toolbox. I click save, upload it.
And then I clear the cache and I refresh the page. On my part, I can only add that I frequently find myself using not Fiddler, but browser development tools. Because with the browser development tools, and I'll include reference, you can do the same kind of trick what Fiddler does. You can say, please serve this JavaScript locally, except you point to the folder, you tell the browser dev tools, this is where my file lives. And browser takes care of that. The nice thing about it, you can actually get to these fragments of JavaScript that are served as part of the page, as part of the list. You can start fiddling with that.
in line and rerun them in line. And it remembers those fragments. So it doesn't need to be fully externalized. And once you get those sorted out, then you copy paste them into where they belong. Let's say form a list. So I find that kind of helpful because you work inside the browser. Setting it up requires some attention to details. I find like, oh, where's the folder? And sometimes you forget to switch it off. And then you find that people say, oh, we've got problems here. And it's like, I don't have any problems. Everything works on my machine. Yeah, of course it does because it keeps serving your version of the file instead of a version from the side. Debugging.
I don't know. I used to step in through the browser. It gets a little bit messy, obviously, with all the includes and scripts coming from left, right and center. Things like React are notoriously difficult and Angular. I dealt with a couple of marketing sites and it's notoriously difficult to debug. You have to roll out local environment effectively. How do you deal with debugging? Because every time I touch new site, I guarantee there is a debug statement somewhere that hasn't been removed.
Yeah, you're right. It can be painful. And I find even just some sites, and I don't know what causes it, but like even the putting a breakpoint in, it just, it won't work in some of the browsers. You put a breakpoint in the one line and that is not the line of JavaScript that it breaks on. So yeah, it can be painful. Console.log is a pretty popular tool. So it's just kind of old school. And it's, you know, as bad as it is in JavaScript, Liquid's even worse because you just don't have, you know, you end up doing a lot of console.log's equivalent in Liquid. So it is kind of a pain. You can actually use console.
Make liquid to generate console.log. Exactly. Exactly. Sometimes if, you know, alerts. Alerts are also, you know, helpful to see. Oh, please no. On that note.
But yeah, unfortunately, it is a bit painful, especially if you're doing a React thing, as you mentioned, that, you know, there's all these different things. The code is actually kind of compiled and you're doing TypeScript. You know, if you're working on a larger project, it's certainly worth the investment to make sure. Because if you do kind of get every, you know, get all your ducks in a row, you know, you can, in theory, kind of step through your TypeScript. And that's worth it to figure out how to do that. Because without that, you can be needle and haystack type territory. And I think we come to the end of our list. So to sum it up, basically, location. The summary would be, it depends. I didn't say that. You told me I couldn't say that. It depends on what you're doing, whether you're localizing or whether you're going for global things.
script liquid source control types. There's so many places, so many things. As you mentioned, the number one thing is to be consistent. If you put in your script and code snippets, just keep doing that because then I know where to look. I don't have to hunt for your slice of script, regardless how clever or how brilliant that script might be. And you did do a part one, two, three, and four of where the Dynamics 365 portals code. So there are a couple of things like no longer Dynamics 365 and no longer portals, but...
the word code still stands. So that didn't age well. Well, you know, I'm actually, because those blog posts were from September 2018. And do you know what? If I went through them again, I bet that it's pretty, you know, it's 95% all still very accurate. So that's what, four and a half years ago? We'll include references to those where Nick talks about the differences. And we didn't talk about header and footer. I got it just with that. It's just not a good idea to include any script in header and footer at all. Apart from tracking, maybe. Yeah, usually what we see in the header and footer is what people are trying to do.
like shopping cart type things. They want a little shopping cart icon with how many things are in your cart. And that's where people are, oh, it worked the first time, but why, you know, every time I refresh, because what they'll do is they'll just do a liquid fetch that says, oh, get me how many people are thinking in my cart. And then they refresh again. It's like, oh, it didn't change. And that's when you get into that, using those substitution tags, because that header is very much cached at a different level. Because they'll be like, oh, I even cleared the cache. It's like, well, that's a different cache. We come into a footer of our show where we keep repeating the same thing over and over again and wonder why show doesn't end. That's probably because I didn't press the stop button yet. As a closing note, like let's throw in some.
useful tips on debugging. So my tip would be, if your client is unsure whether caching causing a problem, client-side caching causing a problem, I always say, do me a favor, fire up development tools. So you go in your browser, you go to be exact dot, dot, dot on the right-hand side, more tools, developer tools, and then you go on the Web Monitor tab, and you say disable client caching. And you say, just run the page. Just leave that open on the side or whatever your DevTools open. And just refresh the page. Control-R. Browser just disables completely client-side caching and retrieves every single page. So that way you can definitely eliminate any problems if they're cache-related. If something still doesn't work, you're saying it's not cache-related. Yeah, that's great advice.
Usually I just tell people open up a different browser because usually people have their favorite. So if you're a Firefox person, open up in Chrome or Edge or something like that. So what's your favorite technique when it comes to JavaScript? Alerts. I think I already covered that using alerts on your page to see where you're at. That's I think the most modern way to do it. If any client out there, if you see alerts on your web page, that's a good indicator that Nick had some say in developing that portal or page. The other advice I would say is when you're doing your little console logs, even though sometimes you might be frustrated and you might want to put swear words in there, avoid that because sometimes those get left in there and you'd really hate to...
you know, see a bad word in an alert at some point. So, and then you get a call. Why the did you put that in your JavaScript? On that note, thank you very much for your time. And we didn't even touch on the brand new VS Code editor. Using that, I'm waiting for that to mature before I use it for JavaScript editing because it feels a little bit on the side. It's scary just jumping into hot waters. So we'll talk about it some other day. Cutting edge. Bleeding edge. On that note, thank you very much for your time. Thank you, George. I look forward to the next one.
Next one. And next one, we're going to talk, what were we going to talk about? I think we're going to talk about, I think you're going to show me the money. Payments. Everyone wants payments. So next one is going to be about payments and power pages. So until next time, thank you very much and goodbye. See you later, Jordan.