Skip to content

Instantly share code, notes, and snippets.

View mazeeblanke's full-sized avatar
🎯
Focusing

Ewomazino Ukah mazeeblanke

🎯
Focusing
View GitHub Profile
@mazeeblanke
mazeeblanke / what-forces-layout.md
Created September 27, 2021 17:44 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
<?php
...
$app->get('/hello', function ($request, $response, $args) {
return $response->write("<br>------------ CENTER -------------------<br>");
})
->add(function($request, $response, $next) {
return $next($request, $response);
})
<?php
...
public function callMiddlewareStack(ServerRequestInterface $request, ResponseInterface $response)
{
if (is_null($this->tip)) {
$this->seedMiddlewareStack();
}
/** @var callable $start */
$start = $this->tip;
<?php
...
protected function seedMiddlewareStack(callable $kernel = null)
{
if (!is_null($this->tip)) {
throw new RuntimeException('MiddlewareStack can only be seeded once.');
}
if ($kernel === null) {
$kernel = $this;
<?php
//route middleware
$mw = function ($request, $response, $next) {
...
$response = $next($request, $response);
$...
return $response;
};
<?php
class Route extends Routable implements RouteInterface
{
use MiddlewareAwareTrait;
...
public function finalize()
{
if ($this->finalized) {
<?php
...
protected function addMiddleware(callable $callable)
{
if ($this->middlewareLock) {
throw new RuntimeException('Middleware can’t be added once the stack is dequeuing');
}
if (is_null($this->tip)) {
@mazeeblanke
mazeeblanke / index.php
Created November 6, 2018 15:58
A simple slim app
<?php
require __DIR__ . '/../vendor/autoload.php';
$config = ['settings' => [
'addContentLengthHeader' => false,
]];
$app = new \Slim\App($config);
//route middleware
@mazeeblanke
mazeeblanke / App.php
Last active November 10, 2018 17:42
Slims except of app.php
<?php
class App {
use MiddlewareAwareTrait;
...
public function run($silent = false)
{
$response = $this->container->get('response');
@mazeeblanke
mazeeblanke / middleware-stack-example.php
Last active November 6, 2018 10:15
A simple illustration of a middleware using a stack
<?php
class App {
public $tip;
public function add(callable $callable) {
if (is_null($this->tip)) {
$this->tip = $this;
}