DrupalCon Prague 2013

Creando sitios web muy rápidos con Drupal 8

Wim Leers  · 


HTML (pincha para descargar)



Extracto de la transcripción automática del vídeo realizada por YouTube.

good afternoon everybody is this too loud not loud enough great I guess it's good okay so my name is a limb Lear's and this session is about deliberately fast websites and I'm a speed freak so I really hated my website slowed slowly maybe one of

you also has the habit of on a mobile device when you're loading a website counting to five and if it's really long enough five seconds just closing in town because it's annoying the hell out of you at least that's what I do so my goal is really

to have every website load fast so mobile devices are not so I actually worked for aquia on the spark project which you may know but it doesn't mean and I work just on spark stuff I also work on related stuff and Drupal 8 or in the past few months I've

been spending some time working on the performance improvement specifically interpolate and this talk is going to be about some of the improvements interpolated should make your lives easier your site's faster and your site's more scalable these are

not things that were built just by me these are things that were built by community by consensus lots of smart people collaborated on this and these are just this is not everything this is just a few things that I find personally really interesting so they're

better instead I replied in Drupal 8 some of which you can apply in Drupal 7 as well and I hope that they are abuses of use to you as well and that you can really leverage them so hopefully you'll find it interesting so what this talk is about it with

Drupal 8 oz better than 70 rounder caching client-side caching and pluggable CSS and JavaScript optimization which is a whole lot of words but you'll see that it's actually really interesting and not that hard anymore interpolate and of course some

of the things that we should have and hopefully we'll have but that aren't there yet so some of the things that still need to happen so let's get started the first thing my personal website was for a very long time on Drupal five until 2011 when

triple seven was already around for quite some time and I didn't find the time to upgrade 60 I skip six went from fri from five to seven and since i'm a speed freak I really care about performance I wanted to make sure that my website loaded as fast

as possible so it could be some sort of example of how you can make a simple website of course because it's not complex how we can make it fast and to my surprise and i'm not sure if many of you have noticed this or many of you have tried this but

if you try to make a website on Drupal 7 or even a single page load with our JavaScript good luck but it won't work because Drupal 7 will always load Jake righteous through peluche s and Drupal settings so that's not so great of course and in Drupal

7 we fix that so in Drupal droop in Drupal 8 we fix that of course not seven so in interplay what we're doing is too important things we're declaring all dependency so whenever you load a certain assets you declare which things it depends upon so the

trip will know is which things to load so that it doesn't have to be due to stupid thing anymore of always loading jquery and drupal two chairs and we're using power and attached or hash attached instead of drupal at css3 will add chase and drupal

at library and I'll explain why that's much better in a second and sadly this problem as in the problem of Jake redditch a stupid a yes and drupal settings always loading is something that is utterly unfixable and rupal seven unless you break the API

and ethics I'm not sure if he's here Peter drug baited hook notes attached a Belgian guy he's bravely working on a workaround but yeah it relies on a settings of PHP setting it essentially changes the API so there is no way to make it work good

in triple seven out of the box without breaking the API as breaking all of contrib so we can do that but we can you can't fix it for individual sites by applying his patch hopefully it will end in core and then you can do it as well but then you will have

to declare all your dependencies and if you use contributed modules that don't do that you'll have to update those in any case I let's take a look at fixed so if you look at an example JS file for example table select ljs and Drupal 8 there is

some javascript in there and we're using to things that aren't part of JavaScript itself we're using Drupal tupelo behaviors is what you see up there and we're also using jQuery the dollar sign dollar complexed so those are the two things we're

using and if we're using those then we should import them into the current closure so jQuery is use Drupal is used and you see these things at the top and at the bottom of the code example what we're doing essentially is we're declaring or using

jQuery or declaring we're using Drupal the Drupal object that is available through Triple H yes and we put them in the closure so we rename jQuery to dollar sign so that's easier to use that's the convention you can you can rename it a llama if

you want doesn't matter so if you use it you declare it in the closure I keep pressing the wrong key this is the right one so that's the JavaScript site you declare you your dependencies by putting them in the closure the second step is to do the similar

thing on the phb side because Drupal needs to know which things it needs to load so the PHP needs to know right so we have table select HS in the library but the library also declares to dependencies one on jQuery one on Drupal very simple so the rule is jQuery

and Drupal are in the closure of the javascript file so we should also declare dependencies on the PHP side very simple the next step is to abandon Drupal add CSS and J's because we don't want individual assets anymore because you can't declare

dependencies for those so instead you should use triple at library you should always always use libraries because then you can declare the dependencies properly however you should always also abandon Drupal at library because you should be using barn detached

so what you're doing is essentially the same thing but you're doing it in a slightly different way and the reason you can't use it you will add functions anymore is because they use global state and that breaks caching because for example if you

have a block and a block uses food at CSS and you add it through Drupal at CSS and it's done cashed in the render cash in the server database and then you retrieve it at a later point in time because some other page wants to use that then the Drupal at

CSS goal won't occur anymore because the code that generated the block won't be run because it's already cashed the HTML is cached in the database you retrieve it hence the CSS won't be out of times I brakes released won't look as it should

look so don't use to Drupal add functions you can do it in Drupal 7 you can use parent attached in Drupal 7 as well because it breaks caching just use pound attached always the conclusion here is really simple you should always load assets by attaching

libraries that's it results in better DX because there's less or no magic rather going on you have cacheable ran their race which you wouldn't have otherwise because if you use triple add functions something is happening with lloyds okay so you

should should always the advantage is also that you have casual event arrays which you wouldn't have otherwise because it would be calling triple add functions only the required SS will be loading so loaded so no more jQuery that is loaded while you don't

even need it and dynamic content as in the one that you HX in will also have the proper exits without having may be the same as loaded twice or all sorts of weird things that can happen when you use the triple add functions and all of this you can do in Drupal

7 so to prepare to move to Drupal 8 just do things correctly or as well as you could in Drupal 7 and you'll be s or twice you'll be very it'll be super easy to upgrade so it's one thing it's a tiny thing but can have a big impact so the

next thing one of the things that has gotten much more expensive in Drupal 8 is a rendering of entities and to get to Drupal 7 or better performance levels we need to finally achieve render caching of entities we've had to render cache API since seven

at least maybe six I don't think so but we've had it in seven but we aren't really putting it to use because there are still too many things breaking the render cash and that's what we're fixing an eight so essentially what this means is

if render caching works for entities and users with the same combinations of roles for example editor and authenticated all those users maybe ten maybe hundreds maybe a thousands they will all get the same chunk of HTML without having to regenerate at HTML

over and over and over again which is pretty expensive so the goal is essentially to really use render cashing it was already available but we weren't really using it and the thing it was blocking it was we're not yet putting the right data in there

but we'll get to that in a second so before we're almost I we're not yet there we're almost there and while this conference was going on two days ago the patch got committed that adds through an entity grinder caching but it doesn't yet

at the render caching for notes and comments which are the most common entities of course so that's coming soon but it's not there yet we're almost there but before we got there we had to do quite a lot of things and these are this is just a tiny

selection of thing so cash tech support is something very cool very interesting you can do a lot of things with it and it's useful for many things not just for render caching you should definitely look at it contextual links were fundamentally incompatible

with around cash this is what one of the reasons it couldn't work in Drupal 7 the new indicator the new and updated indicators are at small markers they were also fundamentally incompatible so does another reason why Drupal 7 couldn't do that so we're

almost there but still not yet and that actually brings us to this nice quote that I'm sure most of you have already seen at some point in time there are only two hard problems in computer science naming things and cash in validation and naming thing is

[ ... ]

Nota: se han omitido las otras 5.170 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.