Placeholder Image

字幕列表 影片播放

  • This is a video about the jam stack way of developing on deploying sites to the Web.

  • I've bean building things with Jam Stack for quite a long time, I think.

  • Actually, before the term jam stack was around on Bean come really excited about the possibilities of using Jam Stack.

  • What it could do for us is developers and also for user's as well.

  • So this is, Ah, quite a long video.

  • I go into a little bit of depth.

  • We start with an introduction to what the jam stack is, what the term is, what it means on then also some of the advantages of the jam stack.

  • We compare it a little bit to other stacks, like the lamp stack, which is something that might be a bit more familiar.

  • Toe many Web developers, and then we'll start to look through a bunch of examples.

  • So there are six examples can practically showing taking one site from a single file, a statically generated or statically written with my own hands.

  • Html file.

  • Deploying that to a content delivery network but then evolving that page, turning it into something a little bit more dynamic, turning it into something that has things like localization on clients.

  • I'd rendering another the other bits and pieces, and so that's a set of examples that grows throughout the video.

  • You can jump into any of those points and jump straight into those examples, or you can watch the kind of evolution of the whole thing as we go on.

  • Then, at the end of the video a CZ, we do a little bit of a wrap up.

  • There's also another demonstration, which looks at how you can start to use the jam stack in your own infrastructure.

  • So if you are already building sites using a different architecture, how can you add jam stack next to that?

  • What's an easy route in to do that?

  • So there's an example of that at the end as well.

  • At the end of the video, there also are a bunch of resources and links for you to take a look at on.

  • I hope it's useful.

  • So, um, let's get started on start to look a TTE exactly what this jam Zach thing is right then.

  • So where where to begin?

  • Well, we're thinking about an introduction to the jam stack, then it's probably worth our while just considering that this is an approach to delivering websites, and it's not the only one.

  • There are many, many approaches to delivering websites.

  • We've been at this a long time now as as an industry, and we've evolved a long way.

  • It used to be when we first started out.

  • This is an incredibly nice, simple diagram to begin with.

  • It used to be that, you know, when when we started building for the Web would create assets, we put them on a Web server, and then it would come along in a browser and we'd ask for stuff.

  • And then we get the stuff, and that's that's a lovely situation to be in.

  • You know, it's very seems very simple, very straightforward.

  • Now we'd have this relationship where we'd create assets, put them somewhere that they become available.

  • And then when someone came along with the Web browser and asked for those resources, we'd simply deliver them to them.

  • And that was great.

  • And it's did it stood up well for folk for quite a while and on.

  • That was kind of nice and efficient, but we soon run into limitations in that you know, these things were were kind of all there was static.

  • They weren't.

  • They weren't able to be changed based on what people ask for.

  • So the experiences we were getting seemed to be quite static as well.

  • So we try to add something new to this.

  • We started to add some kind of level of dynamism at the server level.

  • So now, instead of just asking for stuff and getting stuff, their server would do stuff as well.

  • We'd have this, this script, this logic that would be executed at the server level for every request that would generator, view and then return it to the user.

  • And that was great because it meant that as we were requesting things we could we could build things up on the fly so we wouldn't need to know every permutation that was being requested or or we might need it ahead of time.

  • We could respond to the needs of the user and create something dynamically on return it.

  • But it didn't mean that the responsibilities of this server Now we're we're quite different now.

  • We needed to make sure that for every request that came in, we had enough enough capacity here enough horsepower to be ableto service every request and get something back to them quickly.

  • So that soon led Thio a slightly different scenario.

  • So we started to introduce different bits of infrastructure.

  • So rather than just having a single Web server that was creating those views, we started to add many Web service to handle the traffic.

  • And we'd perhaps put something in front of those Web servers like a load balancer that would say, Okay, well, this request will go to this Web server.

  • This request were to another Web server gonna share the load across those servers.

  • And we started to do more things like abstract where the data lived rather than the data being on these Web servers as well.

  • We start to say, Well, let's let's abdicate the responsibility and share some of the load with with servers that are specific to that Andi abstract those out as well.

  • So we got to a point.

  • This a request from a from a page for from a user for a page would travel through all of these different bits of infrastructure, gradually assembling a view that would get returned to the user into the browser rather than having something ready to go.

  • We also started to think about well, maybe we could find some assets that are kind of just static and don't need generating on the fly.

  • And maybe we could put those in a different location.

  • So we started to introduce things like a CD en, which is a content delivery network, a network of machines geographically arranged so that wherever the user arrives from, some of those assets could be served directly from their, whereas others would have to go and go through this journey and get built up over time.

  • So all of this kind of added to the infrastructure and the the pieces in play for serving the request off a user ensure it got complicated on dhe.

  • We got more sophisticated in the kind of things we're building on.

  • Our infrastructure got more complicated as a result.

  • Luckily, though, you know, we we've been learning and we've been building new tools so we don't have to stay in the same picture that we've had for such a long time.

  • Now we understand that the needs of users have changed and what we what we expect to build has changed.

  • But So is the tooling that allows us to get there.

  • So you know, a few things have changed.

  • Browsers have got more capable.

  • You know, the Web browser that you'll be viewing this site and now is very different to the one that we were using at the beginning, when everything was was a little bit simpler, browsers away, more powerful, way more capable than they ever used to be.

  • And we can.

  • We can use those to great effect also as a as a consequence of building so many sites for such a long time, we as an industry of matured our processes.

  • We've really got a lot better at the way that we build sites on the way that we we can deploy them so we can start to make start to take advantage of these.

  • These maturing process is, and also tooling has improved.

  • You know, the things that enable us tow Thio generate our code to manage our code to deploy our code and all of the things around that that's all improved as well, so we can evolve our approach as a zoo result of all of these things improving.

  • So let's get to this small question, then it.

  • Since we're looking at an introduction to jam steak, what is the jam stack?

  • Well, there's a couple of ways that we could we could answer that we could We could ask, You know what does jump stacks down for?

  • And we could ask, What does John Stack mean?

  • And they first grants.

  • You think?

  • Well, these are the same question, but but not quite.

  • Let's let's let's dig into both of them in terms of what does jam Stack stand for?

  • Well, the word has come about by considering JavaScript AP eyes and mark up to make up the jam of this jam stack.

  • And certainly as we go through that, this video will look at how we use markup, how we use JavaScript and how we use AP eyes to create experiences in the browser.

  • But there's more to it than just what it stands for.

  • Let's also consider the words stack as well, for just for just a moment now.

  • What do we mean by stack in the first place?

  • Well, I think we're talking about where Web technology stacks.

  • The stack is the layer of technology which deliver technologies which deliver the website or application is the thing is the set of tools that make up that delivery.

  • So when we think about what it stands for, well, that's one thing.

  • But I don't think we're any the wiser, necessarily toe to talk about what?

  • What does Jam Stack actually mean?

  • And what's the result on How do we use it?

  • This is about the best definition.

  • I think I've I've encountered above Jam Stack, and that is James.

  • Stack means fast, insecure sites and APS delivered by pre rendering files and serving them directly from CDN, removing the requirement to manage or run Web service.

  • There's a lot to unpack there, and we'll do that over the course of this video.

  • But I think this is.

  • This is a good descriptive meaning for Jam Stack pre rendering the files so that you don't need to manage a Web server later on.

  • It's kind of a return toe capabilities that we might have had in this world, but there's so much more that's come along, too.

  • To empower things around this that will get to shortly, you might think, Well, there are a lot of Stax already.

  • You know, I'm aware of different approaches of building things for the Web.

  • They're all of these different stacks that we might choose from with different technologies on dhe, and that's that's fair.

  • But let's let's let's use one of them as a bit of an example.

  • Just as for means of clarification and a bit of comparison till it's let's talk about lamp stack for a little while now, Lamb Stack that stands for Lennox, Apache, my SQL and PHP.

  • And this is a very popular, I think, the most popular combination of technologies for building out a Web experience that exists on the Web at the moment.

  • And each of these, these technologies plays a certain role on these other stacks.

  • That's, you know, we've listed up here effectively.

  • They play into that place into the same kind of environment.

  • But some of these technologies air switched out, but ultimately they do the same kind of thing.

  • We end up with a system where on a Web server where we've got something that is delivering our operating system for us tow build on in the first place.

  • We want a layer for data access being my SQL here for a database and the service is attributed to that, Then we got a layer for doing pre processing or the actual scripting and processing and handling of the logic and assembling the views in this case is PHP for that pre processing layer and then some kind of Web server that will do things like the 82 p routing and the actual serving of of assets and passing things along down the stack, too.

  • To get the resources we need now in the lamp stack often find these things combined in a single Web server.

  • But over time, as load increases, a typical thing to do is well, we won't have.

  • One Web server will have many Web servers all running these bits and pieces and other described a few minutes ago.

  • And sometimes we'll start toe abstract things like the data layer out of these, but ultimately was still looking at a stack, which include reaches all the way back down to the operating system right the way through up to the actual routing and the handling of the http requests.

  • Meanwhile, if we to look at the jam stack is, ah, a comparison to that, the stack looks quite different.

  • The diagrams a little bit different here, but we're catering for the same kind of things.

  • We're still talking about a seedy P routing and serving.

  • We're still talking about data access.

  • We're still talking about processing in a run time.

  • A key difference here is that this run time, the processing layer in effect, the operating system, if you like, that lives within the browser here.

  • So we're not having to reach away down into an operating system that's provided to us by the client.

  • That sir, the runtime exists right there in the browser, the AP eyes, the data access.

  • We've kind of abstracted that away.

  • That's kind of not part of our domain.

  • Now there are AP eyes that exist out in the ecosystem.

  • Now that we could make use off, which we don't have toe manage ourselves, we can request access to those via their AP eyes, and we typically do that using JavaScript.

  • So that's why we get this thing kind of trinity of mark up, delivering content and then, if needed, we can start to use JavaScript in the browser to talkto AP eyes and get, get content and embellish and enhanced the experience here in the browser.

  • They're still rooting and serving, going on but typically in a jam stack world.

  • What we're doing is we're pre generating all of those assets they can so they can be served from a very simple, static server or even better, still, a CD en.

  • This is the kind of thing that could be managed for us.

  • It's almost like a service that's been completely abstracted away since there's no internal kind of clever logic logic here, which is coupled to the way that our system, our application, works so mark up.

  • Jobs rips in AP, eyes kind of moved the stack kind of away from the server and over here, So Jam Stack really is about having things that are pre rendered.

  • It's about leveraging the browser and the power and the browser and the technologies available to us in the browser.

  • And it's about operating without a Web server.

  • And all of these things bring is a bunch of different advantages.

  • We'll get on to that in a second, but I just want to kind of put these two things, but side by side for a second.

  • And consider you know what the stack looks like here in the depth of the stack that reaches all the way down to the operating system, right the way up through the data, the scripting and even the handling of the requests.

  • And compare that over here toe What happens with the jam stack, where Stack is kind of moved up a level it's closer to the browser is closer to the user.

  • We're not dealing with operating system infrastructure.

  • We're dealing with a run time which is provided to us in the browser so that we can use JavaScript right there to do the dynamic things we need right there in the browser and sitting on top of mark up and being out to call AP eyes.

  • So this means that if we're if we're thinking about a pre generating pre rendering things, working without a Web server, it feels like we're getting a bit closer back to this.

  • This kind of environment, this kind of flow, where we're pre generating things, putting them somewhere that they could be found, and then a request comes from a user to get this stuff.

  • They give that back.

  • This this, um, returned to this simplicity was starting to get appreciated quite a long time ago.

  • Aaron Swartz has done a lot for the open Web.

  • A lot for work project for Web development in general.

  • Coined this term.

  • He talked about Bake Don't fry in a block post that he wrote back in 2002.

  • Where has his instincts were to front, trying to get back to her?

  • A place of more simplicity where things could be much more robust if only we could find a way to get to this point.

  • We were not building our response to a request every time frying it on demand but instead baking it ahead of time So it's ready to return.

  • And this idea of pre rendering that we're talking about and having things ready to go for when they requested there are lots of reasons we might have motives for that.

  • I think about it, is doing the work now so your servers don't have to do it later.

  • Kind of lightening the load in the complexity at request time on doing this work up front.

  • I also like to think of putting some distance between the complexity and the user again, thinking about Theis, this world where perhaps we're having to have moving parts of all of these stages when a request comes from a user knowing that with confidence, all of these things will work perfectly every time.

  • And the transmission between these things is gonna work perfect every time.

  • There's a complexity and potential failure points there, and the more we can reduce those, and the more we can put distance between the user and that complexity, the better.

  • We'll talk about how we put that distance between those two things at shortly being in a situation where we have a much simplified of hosting scenario where we've got pre generated assets this hugely simply for simplifies deployments.

  • And I want to just kind of illustrate that point.

  • Just a tiny bit.

  • Eso I've kind of adapted our our diagram from earlier, where we've got a request in a traditional stack.

  • This maybe hitting a seedy end but also hitting a load balancer, Web server database servers and the request goes through all of these things.

  • When we're talking about our development and our deployment of our code and are content will that requires action being taken and updates happening to each of these bits of infrastructure.

  • Sometimes there are many of these bits of infrastructure next to each other.

  • And so as we're deploying in developing and deploying our code, we need to make sure that we can predictably update all of these things.

  • And they all stay in lock step so that now the result is always gonna be something predictable.

  • We compare that to the situation with the jam stack, where everything is pre generated and ready to go at a content delivery network, it means that our process of development and deployment that's radically simplified that that is a situation where we're essentially updating 11 resource in a known in a known and predictable way.

  • This unlocks all kinds of opportunities for us, and one of those things is that we can start to use version control for everything.

  • Now, yes, it's fair to say that we might want to do that in this environment as well.

  • Of course we do.

  • But when we're in a situation where we're building a known asset and putting that that one set of assets in a single place, it means that we can start leveraging things that a version control and tools like get which will come to you and little while and start using that.

  • In our examples, we can have the version control used for everything right down to the configuration of how that the Cdn works right through toe.

  • All of our content order the code and then that version control can reach all the way through to the hosting environment and through to the deployment process so that we have a very predictable way of updating on deploying our coat.

  • There are few other advantages of jumps.

  • Actor, I think a really important to call out.

  • And those air security performance and scale are just spend a couple of minutes just just describing those just just insured.

  • So, in terms of security, how does the jam stack improve our outlook?

  • The security for websites?

  • Well, as you might imagine from the diagrams we've just seen, we get a greatly reduced surface area when where we're working with the jam stack.

  • You know, if we think about this comparison once again, the kind of infrastructure we have in play and the kind of infrastructure we need to secure, even against the request that we know we're gonna have to pass through all of this infrastructure, aunt have code that executes in all of these different environments the Maur infrastructure we have and the more moving parts and more code we have, the more we have to secure.

  • Simply put with jam stack you know that there are fewer there a few of moving parts in the scenario I can.

  • Sometimes glib Lee could have comment about the fact that there is no server more secure than the one that doesn't exist.

  • So getting some of this infrastructure and these moving parts out of the out of our hosting scenario just creates a much Maur unmanageable security profile for us.

  • There are far fewer and fewer moving parts to attack moving onto performance.

  • Well, when we think about how we've tried to handle performance in our traditional stack, the kind of stacked that I'd been illustrating well, often what we'll do when we're trying to build out that kind of hosting environment toe be very performance in tow, respond to requests quickly is we'll start to add some static layers to that.

  • What I'm talking about there is I'm talking about cashing.

  • So if we go back to our diagram once again, each level of the stack in order to try and speed up the process of this request, hand passing all the way through the infrastructure and back at every level.

  • We try and minimize the dynamic things we have to do here.

  • So ah, Web server, we might at what might look at will what templates are commonly used with what data and can we cash that response?

  • So it's ready to go when a request comes into it that reaches down as well into things like the databases where we might try and cash comin queries for the data.

  • So a request that comes in there actually isn't doing something dynamic.

  • It's saying this is a common request, so I can serve that statically on return that much more quickly.

  • That's true at every level level through right through to the Cdn, where some assets of cash but some of them will need to be refreshing updated.

  • If we compare that with a jam stack, every time we do a deployment into our cdn effectively, we are updating the entire serving cash.

  • There is no logic that we have to manage this kind of this barrier between what is cached on what needs to be dynamic.

  • And it's this logical separation, each level that adds complexity on ads, complication toe how we deploy and manage and maintain these bits of infrastructure.

  • Cashing is hard.

  • Cashing is one of those things that's universally understood.

  • To be hard in Web development.

  • That's more you can simplify the model of the cash and ideally have something that takes care of that for you.

  • Wholesale, the better off we'll be.

  • But it's also interesting to note that, you know, for all of the, um, benefits we might we might sometimes hear about for a dynamic back end.

  • The way we try and make it go fast is adding static layers into it.

  • And this isn't again an area that will kind of think about a bit later on.

  • When we talk about what truly is dynamic and what truly ecstatic, Let's move on to scale.

  • So when we're talking about stick scale we're talking about, you know, how many how many requests can we can we manage with a particular piece of infrastructure?

  • Traditional stacks add infrastructure in orderto in orderto cope with large scale.

  • In a previous life, I worked doing technical architectures for large projects.

  • And it was always a tough question to say to answer How much?

  • How much will our infrastructure costs for this project?

  • Because we kind of needed to know well how much traffic we're going to get.

  • And also, how complex is it for us?

  • Is it going to be for us tow handle of each of those a crest requests and as a result, how much infrastructure will we need?

  • Adding infrastructure to win crude, too?

  • Thio handle scale looks a bit like this.

  • I mean, certainly adding these cashing layers that's gonna help to a degree, because that lightens the load on what needs to be be dynamically, that work that needs to be dynamically done.

  • But knowing that there's gonna be more and more traffic here that each of these levels the result is that we start, we start to ADM.

  • Or more bandwidth in, we start to add more servers, more capability, more capacity, rather toe handle this increased load.

  • More service means more cost, more complexity, our deployment to getting more complex as we manage things across here and this is just catering for a live environment.

  • We're not even talking about things like staging on testing environments, where we really strictly speaking, we should be replicating all of these.

  • So this is a different scenario to the jam stack, where by by design and by default, the jam stack where everything is already cashed, there's no additional dynamic work to do this kind of on demand work to do so we're at an optimal position, already serving everything from a content delivery network which it, from his very inception, was designed to handle things at at high Load.

  • That's exactly what therefore, So we've got a much better scenario over here if we can work in this way.

  • Okay, that sounds fine.

  • But you might be raising an eyebrow and thinking Well, okay, but what you're describing is a return to this.

  • And I thought this was a problem because everything had to be.

  • You know, we were hand making all of these assets and putting them there, and we don't we don't know howto service.

  • Things are a little bit more custom or dynamic.

  • Well, that's a fair thing to call out a common common point of concern.

  • But luckily, the whole reason that jam stack exists and the whole reason this term really exists is we've moved on, you know, where we're lucky that we've We've We're lucky that we've got predicts this experience.

  • Now we've been building on learning about new approaches and you tool.

  • So things have evolved.

  • We're not quite in the same scenario we were before, and I do tend to think of it as having all of these enablers.

  • Yes.

  • We used to think of things in this world a static sites.

  • That word isn't gonna cut it anymore.

  • Things aren't static in the same way at all anymore, where there are benefits from hosting things in this way.

  • But we've really evolved tools and the systems have evolved.

  • I think of it in terms of enablers.

  • We got all of these enablers now that allows to go far beyond what we used to do.

  • And that's what the jam stack is all about.

  • Their enabled enablers.

  • Things such as static site generators.

  • Now static site generator is a script, if you like, which effectively does the work that we used to do in a Web server here.

  • We usedto have templates and data on logic.

  • And when a request would come in we'd munge those through all of those things and generator view and return it well.

  • A static site generator includes all of those things, but rather than happening, happening at request time, this happens at build time so we can generate all of the resources that we need for an entire site by running a script ahead of time.

  • That kind of brings me to touring an automation because it's kind of one of 11 aspect of that.

  • There are all kinds of resources now for how we automate the process of generating our sites, how we trigger those things.

  • How we predictably deploy and manage the assets on the tooling in the automation that has arrived in the industry now really elevates the kind of sites that we can build on the way we build it.

  • And that's what we're gonna look out just a little bit as we get into our examples in a few minutes.

  • The other thing that really has become a huge enabler is the development in browsers where browsers are so much more capable now than they ever were before.

  • Now this doesn't mean that we just offload all of the work and all of the complexity from the back end into the front end.

  • Certainly we can do more than we've ever done before.

  • But there are techniques for progressively enhancing the experience in the browser and responsibly building up layer upon layer of, of, of functionality on dynamism.

  • In the browser, we can leverage all kinds of smart things at the browser level that we just didn't have access to before.

  • And the last and perhaps one of the largest enables, I think for the Jam stack is the number of service is and AP eyes and this thing with the A P I economy has really flourished.

  • We're starting now to see cos emerge with all kinds of special ISMs, that kind of things that we used to have to build in a house with our with our own team.

  • Now companies are starting to see the opportunities of creating those those capabilities on offering them is a service and offering access to them through a p I so that we can predictably request access to those and get the kind of capabilities that we need to bring into our sights.

  • So with all of these things together, this really elevates the kind of sites that we can build from what we may be, we used to think off a static, but now conduce so much more because of all of these things.

  • So over the course of the next, I don't know a couple of hours we're going to look at a bunch of examples on, and it's going to start super simple.

  • We're gonna start with something that which very much is in this territory.

  • But then, over the course of the examples will build up will start introduce static site generators will look at some of the tooling and automation.

  • We are going to start to do things directly in the browser and start to cool on browser AP eyes and then also use JavaScript in the browsers to cool on service is that exist out there in the world and bring in content from different AP eyes and different service is that exist there.

  • So there's a brief introduction to what the jam stack is on.

  • Where we're gonna go on dhe now.

  • I think we'll get into some examples.

  • I'm time it conscious that this is a This is a long video and I've got I've got six world seven examples to show U.

  • S.

  • O.

  • Depending on what you're looking for, you might want to jump right the way in directly to some of the some of those examples.

  • Now, these these do follow a particular pattern.

  • They do follow a bit of a journey.

  • We'll start with something very simple and will use the same example to gradually build up.

  • So to get you know, the full story, you'll probably want to watch each of those in term.

  • However, if you want to jump straight in, I've just put this little index page here so you can see the approximate times have went to went to jump into each each section.

  • So it starts with a very simple static site, a single file beings host being created and deployed.

  • This does look at the simplest way of deploying the sites, not just making it so that's kind of White House there and important.

  • Then, on top of that, we start, oh adds.

  • Some simple JavaScript rendering to that example will start manipulating things in the client.

  • Then, after we've done that, will move down to building that experience that site with a static site generator.

  • So we'll start to use some kind of template ing an abstraction and how the mechanics of that work and then some automation there.

  • And we'll do that so that then our next example example Number four will start to populate that site in that static site that I built with the static site generator with content from an A P.

  • I will be doing that to build time from There will go on, and we'll start using wth e content a p i.

  • T.

  • O Also render out lots of different versions of the site with different localized content.

  • On dhe, start to configure our content delivery network to root people to the appropriate route based on their their location in the world.

  • Then, after that example, six will start to add a bit more client side rendering on start thio Target content to the visitor of the site based on some JavaScript will run in the front end, so we'll start to interact with the browser AP eyes and then do some crime side request to other content.

  • AP eyes to do some progressive enhancement of that page through some cry inside rendering.

  • So those are the examples we're going to work through on a time codes that you have with them.

  • Then at the end, I couldn't help myself.

  • I added just another bonus beat piece of demonstration to think about how we gradually introduce a jam sack site into your existing infrastructure.

  • So if you have a complex infrastructure already, and you and you think where I'd like to start using the jam stack.

  • But how do I introduce the two and blend the two together?

  • This is the time when you can find an example of how we can do that, using some of the tools that will see along the way.

  • But ultimately it's Ah, it's a quick look.

  • Att.

  • How we can start to introduce a jam stack site into around your existing hosting in front infrastructure.

  • So that's the rundown of the demos will get into, uh, and the times that you can.

  • You can access those okay, so I think it's time for an example.

  • Let's let's jump into one of two examples on We're going to start nice and simple.

  • Let's let's not let's not go crazy to start off with.

  • That's just super simple will build up over time.

  • One of the things that will do through each of these examples is the code is going to be.

  • You can follow along as I as I write some of this, but also I'll put this on to get help repositories so you can you can grab the code and step through it as well.

  • Now, this 1st 1 well, that I'm starting with his very simple.

  • So you might.

  • You might not be so inclined to do it, but let's let's start with the same conventions were going to use throughout.

  • So each of the repositories is gonna be available todo your like this.

  • So find that at Jam stack slash Ex one, for example.

  • Number one, that's where this is going to be on this example.

  • We're starting is just very simply and with a static, a very simple, static site.

  • Let's just look again, just as a bit of a reminder about now.

  • What is Jam Stack?

  • What is this thing?

  • We're gonna make it just a bit of a refresher.

  • You know, we're just saying that Jam stack is fast and secure sites and APS delivered by pre rendering files and serving them directly from the CD en, which removes the requirement to manage and run away run Web servers.

  • Great.

  • So what we're gonna do is we're gonna pre render, which is a bit of a fancy word.

  • Really?

  • Well, for what we're doing, we're gonna just make a next e mail file that will then host directly from a seedy end so that we don't have toe bother with Apache or Engine X or other kind of Web servers.

  • It should be nice and simple.

  • What are the things we're gonna make?

  • Well, I've given it away just by saying we're just gonna make html so we just gonna make markup.

  • But as again as a reminder, Jam stack JavaScript ap eyes and mark up.

  • But it doesn't have to be all three.

  • It could be any one of these.

  • I mean, critically.

  • I guess markup is the minimum viable site.

  • You can have the browsers interpret html.

  • They interpret, mark up and do things with them.

  • Even if that mark up, then calls in Jarvis Krypton and makes use of AP eyes or what have you.

  • But to start with, I think we'll just makes a mark up and we'll put that somewhere that could be served as a jam stack site.

  • So tiny Look again at what this could look like.

  • This is the thing we're about to do.

  • We're gonna build something now, later on is this gets more Maur advanced will be building.

  • Things will be using tooling to be building.

  • This will be using some automation Will perhaps, er use a static site generator For the moment, we're gonna you know, I'm just gonna be mashing a keyboard and making a file that will then deploy to some hosting somewhere so it could go into a content delivery network set of servers around the world that we don't need to manage.

  • Its managed is a service, but then it'll give us a year or else so that we can request this page in our browser, get the markup, which we don't have to do anything because that's a LL bean pre built.

  • It will come down the wire and our browser will.

  • Then they got to display that to us.

  • That sounds like maybe over complicating things or being very fiery with my description, given what we're about to do.

  • But these are the principles that will build on overtime.

  • So let's let's jump in tow into making something.

  • We're just gonna make a very simple, static view of a page.

  • First of all, I've got a folder set up here which I think is empty yet.

  • Great.

  • So let's just start coding something now.

  • I love this because it kind of harks back to the things that I was doing as I started to get into a Web development was opening up, uh, text editors writing code.

  • Now, admittedly, I didn't have lots of helpers like this, which is lovely being out how helpers such is that Thio speed some of these things up, but ultimately writing code in text editors and then refreshing the browser to see the result.

  • But I used to love that, So thing kind of makes me reminisce about that.

  • But let's get on with this and let's make a page.

  • You were gonna gradually get to the point that we customize this and make this a bit personalized.

  • To start with.

  • It's going to be super simple, though I am going to, uh, make a little wrapper so I could do some like centering and bits and bobs that will put an H wine in there and say, This is a judge.

  • You do?

  • Um, capitalist.

  • Um, let's, uh, let's put something in here that maybe we'll customize a bit later on.

  • Let's make this nice and positive.

  • Ah, it wasn't love in here.

  • Hoop.

  • Uh, fine.

  • Maybe we should start this up a little bit.

  • I'm just gonna do this all in line.

  • I think rather than creating some CSS files that I'll call in, I'll split that out later on.

  • But for the moment really are keeping this nice and nice and basic?

  • Listen to rely on that, who's, um what else should we do?

  • That's, uh, with, say, 400.

  • And that's, uh, make that that love.

  • Nice.

  • Invisible.

  • Um, Okay, who's okay?

  • So we've made something pretty pretty simple.

  • I think you'll agree it's just a single file.

  • Now, we don't need a web server to serve this.

  • We know this is about as basic as it could get, eh?

  • So I could in fact, just open this up locally.

  • Um, awaiting my brows ago.

  • Let's bring that over here.

  • Um, I don't think there's any huge surprises and what we're seeing there.

  • It's just some static html being served locally from my file system.

  • There's no Apache.

  • There's no engine.

  • Next, there's nothing really clever going on here.

  • It's just it's just a file that we're serving.

  • And as such, this makes it ideal for being out to servers are, as are most ah, basic jam Stack example.

  • Now there's a lot of different places we could perhaps go to host this full disclaimer.

  • I work at MetLife I, which is a company that does this sort of thing.

  • So I'm gonna use Netta five mostly just cause it's most convenient and I think is pretty is pretty simple to get started with.

  • And of course, there are other companies you you could use for this.

  • You could be hosting this on.

  • They get pages or on site or on Google Cloud or directly on Amazon.

  • Web service is maybe in the next three bucket.

  • I'm just going to use this biggest.

  • It's a very, very simple example.

  • Very simple way to get started.

  • And here's my is my directory that we just created.

  • I just created that one index file in it.

  • I'm just gonna drag and drop that onto here.

  • So what's happening here is this is being deployed to see the end.

  • This has gone over to net.

  • If I if I've pushed it around to their different hosting infrastructure on, got a girl for that now so I can look at that.

  • See that?

  • This your you are l.

  • Here's our page.

  • If we did a dinner view source, no surprises, because it's just exactly what we always said is being what we built.

  • It's being so ecstatically is being served from a CD en.

  • I don't have a servant to maintain to keep this alive.

  • It's just it's just there is part of the service.

  • So yes, that was that was terribly simple in terms of what we built.

  • But let's just let's just just refresh what we've done there.

  • Okay?

  • So we we built something.

  • We made something just by typing rather than with any kind of build tools.

  • We deployed it thio hosting environment to a cdn.

  • And then we called up in the browser, seeing the mark up there.

  • So was that damn stack.

  • Let's have a quick sent a check of that.

  • Well, yeah, I think so.

  • I mean, it's just mark up and jump stack sites of jail, stripped a prize and mark up.

  • It's a super simple example, but it's mark up.

  • It was pre rendered.

  • We didn't have to render anything at request time.

  • All we were doing was serving that static asset directly from the CD en.

  • We didn't have to manage any Web servers or have any logic going there.

  • It's effectively just fit serving that file.

  • So in answer the question, was that damn stack yet?

  • I think so.

  • That's Ah, that's probably the most simple example we can have over jams Excite.

  • But now in a position to move on and build something a bit more interesting.

  • So let's gradually layer up with another example.

  • So onwards to our next example.

  • Example Number two.

  • We're gonna add some Java script to what we had previously.

  • You're at once once again, the code's gonna be available on get hub so you can you can just jump straight into what we have there.

  • So it's gonna be a find that at Jam Stack X two.

  • Since this is example, number two on dhe we're gonna use javascript to make the page a little bit more interesting.

  • We're gonna keep on building on that previous example, but move it along a little bit.

  • So, you know, we have just our markup previously.

  • Now we're going to be adding jobs script.

  • At this point, we're not gonna be calling any AP Eyes were gonna come to that a little bit later on.

  • But as I said before, Jam Stack doesn't need to use all of these things you can use.

  • Any of them typically would always include markup.

  • But now we're just gonna add some Java script.

  • There are a few different things that we might do with JavaScript at different stages of development.

  • The deployment on the execution time, eh?

  • So let's just look at that tiny bit.

  • And I'm going to call out this this phrase rendering.

  • So you may have heard people talking about rendering and different types of rendering.

  • I think we should call out a few of the main types of rendering just to explain those and unpack those terms a little bit.

  • So here the three types of rendering that I want to call out and they come into two groups, those client side rendering on the service side rendering.

  • So, first of all, let's talk about client side rendering.

  • Let's talk about what that means when we say quiet side rendering.

  • What we're talking about is executing, jealous, ripped in the browser.

  • So in the client executing Java script in the browser that manipulates the dawn.

  • So in other words, it's changing the what the user sees in the document object model, the view that is rendered by the browser.

  • So that means that this code executes not in server land but in browser lancer this on the user's devices in their browser, it runs client side and that Jarvis Groups has just come down the wire.

  • It might be in the same page.

  • Same file is the HTML.

  • It might be in different files and different assets, but none of it is executed on the server.

  • This is all executed in client side in the browser.

  • Then, if we look at the other side of rendering looking at service, I'd rendering.

  • Sometimes you hear this abbreviated toe SSR.

  • There's a couple of different ways we might think about service.

  • I'd rendering this request time on this build time, but both of these things that are happening on the server, so let's look at request time first of all.

  • And when we're talking about service, I'd rendering.

  • That happens that request time.

  • So per request, what we mean is generating the markup on request in the server and then transmitting that to the client.

  • So it's like a little diagram of this for just a moment.

  • So this is familiar from from the first example.

  • But we've just changed a little bit because what's happening here is when the brows, when the user makes a request from by pointing their browser to you, Earl, that rather than hitting a cdn, perhaps we're hitting a Web server now on that website.

  • But we don't have a complete view ready to go.

  • We're gonna render that on demand as a response to that request.

  • So on the Web server, we might have maybe some templates, maybe some other logic that gets executed to determine what template we we use.

  • Maybe that calls out to data that we need to populate the template with to generate this view that might live on the same machine as science.

  • Get bigger.

  • We typically spit that out, so it's on a different service.

  • It's on a database server, so we might need to make a request for that data, then mash that together with the template to generate the view that we send down the wire to the browser for it to get displayed in the browser.

  • Now, during build time and deployment time, you know, we might be writing the code.

  • That is the logic, the templates.

  • We might be populating data into the database for the content, so those kind of tests are happening a build time but the critical piece off generating that view and then returning it to the user that is happening at request time in service side rendering.

  • That happens a request time.

  • So as this scenario, the other scenario is service had rendering build time.

  • I sometimes talk about that as being pre generation or site generation, but I think perhaps a more youthful tome is still thinking about a service side rendering.

  • But this is happening at bill time rather than a request time.

  • So we talk about that as being, you know, we generate mark up a bill times that is ready to transmit to the client when needed, so we don't need to perform this thing's task of compiling or generating rendering the view per request.

  • This has happened happening.

  • One's a build time.

  • So no, the view of that looks looks like the view we had previously in this diagram.

  • So the rendering happens here, a build time on.

  • Then it's deployed to wherever we're going to serve it from.

  • So in this case, a c d n a content delivery network, so that it's ready for every request.

  • We don't have to do this again.

  • It's ready to send down the wire to the to the user.

  • So both in client side rendering and in service, I'd rendering a build time.

  • They share something in common, and that is that per request.

  • We don't need to execute any logic on the server to then generate a view.

  • These things were all ready to go, and one of the things that you sometimes right here is with the jam stack the stack.

  • You know the technology, stack the things where logic is executed.

  • That's kind of moved to the brows and move closer to the to the user and into the browser biggest here we are executing code that will will change the view and change the rendering.

  • But that's not happening on a server that's happening in Java script.

  • In the client side, neither one of these has has a server that executes logic.

  • So these are the two kinds of rendering that you often associate with jam stack.

  • So the thing that we're gonna build in this next example is going to be something that does some client side rendering.

  • It's a very simplistic example, but we'll get into that now.

  • So let's let's go over to our folder again, eh?

  • So we've got a new filter here for this example.

  • If I just list what's in there at the moment, we've just got the index dot html file that we had before.

  • It's just open that up and refresh our memory.

  • It was just a moment ago, but here we are.

  • It's just, ah, our simple little HTML file.

  • But we're gonna do something here with Java script in the client that's gonna change this view and manipulate that's a little bit.

  • So the moment I got this page, which is a page just for me.

  • It's a very motivational thing for me to see each day.

  • But let's let's change this a little bit.

  • So there's something something that's potentially in recent bit dynamic.

  • So I want to have a bit of a vibe that I get every day from this.

  • A little message you grieves.

  • That's the kind of motivation I need.

  • But let's make this message change every time the user refreshes the page.

  • So in other words, we're gonna be changing what's rendered in the browser with Java script.

  • Every time the user refreshes, it s so let's create a bit of gel scripts over here to do that.

  • J s Andi, what might we have in here?

  • Well, I'm gonna do some copy and pacing so you don't have toe watch me type, but we're gonna do is we're set up a bunch of different messages that we might display in this'll ce things did here.

  • So the moment tells me I'm great, which is a very nice, but let's have a few different messages that might get displayed to me.

  • So yeah, these are the kind of affirmations I need to brighten my day, but will choose one of these random.

  • So let's just put it again.

  • I'm just gonna put in the code rather than having you watch me type it s so I've set up an array of of thes vibes these messages on.

  • Then I'm gonna choose one random with this bit of Java script that just pulls from random one of

This is a video about the jam stack way of developing on deploying sites to the Web.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

JAMstack課程--構建更簡單、更快速、更安全的網站。 (JAMstack Course - Build websites that are simpler, faster, and more secure)

  • 0 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字