Skip to main content
23 votes

How can I make kint() load faster when debugging twig templates?

There are two other ways other users have mentioned for setting the max output levels in addition to the settings.php method mentioned in the question, plus a couple other ideas below: Create a /...
chrisshattuck's user avatar
13 votes
Accepted

Difference between drupal_static and \Drupal::state?

They perform different tasks. drupal_static() only stores data for the current page load (or ajax load). For example, if you are loading something from a database table multiple times on a single page ...
Jaypan's user avatar
  • 17.6k
8 votes

How can I make kint() load faster when debugging twig templates?

Kint is not the only library that you can use for debbuging variables and twig templates. I suggest to use Symfony var-dumper that IMHO is one of the most powerful lib for debuging variables. Symfony ...
marco's user avatar
  • 1,226
8 votes

Difference between drupal_static and \Drupal::state?

drupal_static() is used to cache data within a single page request. it stores the data in a static variable. The class returned by \Drupal::state() handles values that need to be preserved between ...
apaderno's user avatar
  • 97.5k
8 votes
Accepted

Why does loadMultiple load 1000 nodes 9.2 times faster than loading each node one by one?

It's likely that when you are loading individual nodes, you are loading the entity type manager, then for each node retrieve the storage, do a query to get the node data, and build the node. With the ...
Jaypan's user avatar
  • 17.6k
7 votes

How can I make kint() load faster when debugging twig templates?

FYI, as of Devel v3, you'll need to make two updates if you use the top method suggested by @chrisshattuck Go to admin/config/development/devel?q=/admin/config/development/devel Make sure "Kint" is ...
mrsflinger's user avatar
7 votes
Accepted

How to modify .htaccess to serve brotli compressed static assets over gziped ones?

Give this a try # Rules to correctly serve gzip compressed CSS and JS files. # Requires both mod_rewrite and mod_headers to be enabled. <IfModule mod_headers.c> # Serve brotli compressed CSS ...
mikeytown2's user avatar
  • 8,322
7 votes
Accepted

Microkernel with low bootstrap level?

A lot of the bootstrap process happens now implicitly as services are requested. If nothing requests the database service then Drupal won't open the connection to it and so on. The minimal amount of ...
Berdir's user avatar
  • 83.3k
6 votes

Difference between drupal_static and \Drupal::state?

When you want to store hard to compute data in memory you use a static variable. But to store this data in the database the State API is not the right place, despite the similar name: The State API ...
4uk4's user avatar
  • 100k
6 votes

Data coming from entityTypeManager->getStorage is cached data?

load() and loadMultiple() are cached, loadByProperties() is a shortcut for an entity query + load, the entity query is not cached. Do not use loadByProperties() if you know the entity ID.
Berdir's user avatar
  • 83.3k
6 votes
Accepted

Performance is notoriously slow

It appears Azure's docker container services, which App Services leverages, is the cause of the problem. Two big pains with Azure's app service (as explained by Azure support): First, the docker ...
David Lozzi's user avatar
6 votes
Accepted

How do I set the height and width for images that use a responsive images style?

The code for this is actually pretty simple. There are a few important points. For this to work, all of the responsive images in a single responsive image style must have the same aspect ratio. They ...
Patrick Kenny's user avatar
6 votes
Accepted

Is it helpful to improve performance by mysql table indexing?

The cache_default table already has an index by CID (as well as indexes by creation and expiry date that allow old entries to be discarded). Since almost all queries to the table are by CID there's ...
Alfred Armstrong's user avatar
5 votes
Accepted

Leverage browser caching issue

Read this article about Leverage Browser Caching for Images, CSS and JS. Add these lines to your .htacess file. ## EXPIRES CACHING ## <IfModule mod_expires.c> ExpiresActive On ExpiresByType ...
Yuseferi's user avatar
  • 22.1k
5 votes
Accepted

Debugging "UNCACHEABLE" header

This was a good debug deep dive. As mentioned by 4k4 the problem is the first addCacheableDependency line. Instead of passing the host entity itself, I was mistakenly passing the object returned from ...
Kevin's user avatar
  • 27.9k
4 votes
Accepted

Loose compression for all images directly from Drupal

You're looking for this but in D8 - https://www.drupal.org/project/imageapi_optimize. You can still use the tools to do it manually. PNG - Use https://pngquant.org/ first with these settings --speed=...
mikeytown2's user avatar
  • 8,322
4 votes
Accepted

Functional tests performance

Do not use standard (as you said in a comment). Use testing and then create only what you need in the test. That's the main thing to speed up your tests. They are still rather slow, but that should ...
Berdir's user avatar
  • 83.3k
4 votes

Is there a way to minify HTML?

Use spaceless tag. This will not minify the HTML, instead avoids extra whitespace between HTML tags to avoid browser rendering quirks. When cached, can serve better. In html.html.twig {% spaceless %}...
echo's user avatar
  • 1,499
4 votes

Why /Drupal\Core\Form\FormBuilder->renderPlaceholderFormAction is taking so long?

Pretty sure that report is bogus. That's just an arbitrary method, not a controller. They somehow identify that as the controller for that request but of course that doesn't make sense. That page ...
Berdir's user avatar
  • 83.3k
4 votes

Should one avoid lots of use statements in a custom modules .module file?

The use statements alone are definitely not going to be a performance concern. I doubt that we're even talking about nanoseconds here. So that really doesn't matter. I'm guessing that this is resolved ...
Berdir's user avatar
  • 83.3k
4 votes

How to delete nodes without taking a lot of time?

Usually I use 2 approach from the command line. If you call a page from the browser to accomplish the task this will use more time and resources. 1. You can create your own module named drush_delete ...
Adrian Cid Almaguer's user avatar
4 votes

How to achieve clean HTML markup?

A lot of those classes are added by the classy base theme templates. You'll be able to get rid of them with a theme based on stable instead.
Charlie Bamford's user avatar
4 votes

Why does loadMultiple load 1000 nodes 9.2 times faster than loading each node one by one?

This actually has nothing to do with the storage or entity type manager itself. However, it is true that loadMultiple is faster in this case. The slowness comes from \Drupal\Core\Entity\Sql\...
Dropa's user avatar
  • 41
3 votes

Real world experience in scaling and tuning performance

For high-traffic websites you should use multiple servers and load balancer or use simply CDN. Also it's very important to cache as much as possible to minimise load on the web servers. Using Content ...
kenorb's user avatar
  • 14.2k
3 votes

Do non-enabled modules affect performance?

The disabled modules that are not uninstalled but physically deleted from folder system would adversely impact the site performance. I had 5 such modules and due to that, there were additional 10,000 ...
Manish Kumar Namdeo's user avatar
3 votes

How do you improve Drupal performance?

The secret of Drupal performance is in caching and following the good practices. Suggestions: Drupal back-end Enable caching in Performance section. Check Performance and Performance and Scalability ...
kenorb's user avatar
  • 14.2k
3 votes

What is an allternatve approach to many fields in an entity?

Like Clive said, testing would be the definitive answer. But if you look at the mysql queries that will have to be executed behind the scenes, I'm pretty sure you'd find that your bundle A with 30 ...
longboardnode's user avatar
3 votes
Accepted

Downloading, and loading Google analytics script locally and daily with Drupal Cron

This has been built into the Google Analytics module for sometime. In the configuration form, under Advanced Settings there's a Locally cache tracking code file checkbox. It will persist a local ...
Shawn Conn's user avatar
  • 26.9k
3 votes
Accepted

Is putting content in the codebase or the database better for performance?

Quick answer is that the DB should be slower. In reality the only way to know for sure is to profile the PHP code and get a cache grind of it. One being rendered by panels and the other by core blocks ...
mikeytown2's user avatar
  • 8,322
3 votes

Data coming from entityTypeManager->getStorage is cached data?

For anyone coming across this issue; You can also use the entity resetCache without passing an entity ID parameter since the resetCache method can accept empty parameters. See documentation on: ...
rootMaster's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible