Git Product home page Git Product logo

laravel-page-speed's People

Contributors

andysnell avatar caneco avatar carusogabriel avatar f-liva avatar gofish543 avatar japseyz avatar joaorobertopb avatar kenzouno1 avatar khanhvu14 avatar lakuapik avatar laravel-shift avatar lucasmesquitaborges avatar nikonor909 avatar patrickbrouwers avatar percymamedy avatar renatomarinho avatar saifulwebid avatar stakahashi avatar swilla avatar tswestendorp avatar tvbeek avatar vinkla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-page-speed's Issues

CollapseWhitespace Errors

with BootStrap 4.1

Error

    $replace = [
        "/\n([\S])/" => '$1',
        "/\r/" => '',
        "/\n/" => '',
        "/\t/" => '',
        "/ +/" => ' ',
        "/> +</" => '><',
    ];

Suggest

    $replace = [
        "/\n([\S])/" => '$1',
        "/\r/" => '',
        "/\n/" => '',
        "/\t/" => '',
        "/ +/" => ' ',
       "/> +</" => '><', ------ Delete
    ];

Secure server converting all external links to HTTPS

We have external partner links stored the database as full URLs (e.g. http://www.bellavistarv.com) that are being displayed on the website. The website is secure (https). With Laravel Page Speed disabled the external links on the website are exactly as they are in the database. When we enabled Laravel Page Speed on our website, those same external links are converted to HTTPS, which return broken URLs.

javascript Single note compression leads to error reporting

Single note compression leads to error reporting。

var case = 'hello';
// todo document
console.log(case);

document

var case = 'hello';// todo documentconsole.log(case);

Regular matching into multi line annotation

var case = 'hello';/* todo document*/console.log(case);

Issue with InlineCss with angular and ng-class attribute

Detailed description

I founded an bug with InlineCss when when use angularJS and ng-class attribute.
InlineCss search and replace class values but with angularJS ng-class , the parsing create a error in angular.

Possible implementation / correction

In InlineCss there is a preg_match_all function with class attribute but it search all class word like ng-class. I fixed the bug with preg_match_all('/^class="(.*?)"/i', $value, $matches); (line 76)

Your environment

Laravel 5.5, php 7.1, angularJS

Update to Laravel 5.6

- Installation request for renatomarinho/laravel-page-speed ^1.5 -> satisfiable by renatomarinho/laravel-page-speed[1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6].

Console Chrome Error: Uncaught SyntaxError: Unexpected end of input

HI, I am using your component and it really work!

I only have a question, do you know why Chrome report a error with \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class,?

Detailed description

I have this code in the middleware:

protected $middleware = [ \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \RenatoMarinho\LaravelPageSpeed\Middleware\RemoveComments::class, \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class, //\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, ]; And when I check the google console, it throw this error: Uncaught SyntaxError: Unexpected end of input

I tryed to delete the middleware 'CollapseWhitespace' and the error disappear.

Context

It is not very important, but generate a error

Possible implementation

Your environment

  • LaravelPageSpeed ^1.8
  • Laravel 5.4.*
  • PHP: 7.0.24
  • Linux Server Centos

Remove comments middleware has error with IE check

Hi @renatomarinho,
My application shows white page when I use RemoveComments middleware.

<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<head>

If I remove IE check, it's works fine.
Please help me check it.
Thank you so much!

Package Breaks My Download Function

LogicException: The content cannot be set on a BinaryFileResponse instance. in /var/www/html/vendor/symfony/http-foundation/BinaryFileResponse.php:323

Stack -- | --

Stack trace: #0 /var/www/html/vendor/renatomarinho/laravel-page-speed/src/Middleware/PageSpeed.php(35): Symfony\Component\HttpFoundation\BinaryFileResponse->setContent('') #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed->handle(Object(Illuminate\Http\Request), Object(Closure)) #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #3 /var/www/html/vendor/renatomarinho/laravel-page-speed/src/Middleware/PageSpeed.php(26): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed->handle(Object(Illuminate\Http\Request), Object(Closure)) #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #6 /var/www/html/vendor/renatomarinho/laravel-page-speed/src/Middleware/PageSpeed.php(26): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #7 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed->handle(Object(Illuminate\Http\Request), Object(Closure)) #8 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #9 /var/www/html/vendor/renatomarinho/laravel-page-speed/src/Middleware/PageSpeed.php(26): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #10 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed->handle(Object(Illuminate\Http\Request), Object(Closure)) #11 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #12 /var/www/html/vendor/bepsvpt/secure-headers/src/SecureHeadersMiddleware.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #13 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Bepsvpt\SecureHeaders\SecureHeadersMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure)) #14 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #15 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #16 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure)) #17 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #18 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #19 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure)) #20 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #21 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #22 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure)) #23 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #24 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #25 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure)) #26 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #27 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #28 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #29 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #30 /var/www/html/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #31 {main}

My Controller Function that throws this error when using any of these middleware

    /**
    * Download torrent
    *
    * @access public
    * @param string $slug
    * @param int $id
    * @return file
    */
    public function download($slug, $id)
    {
        // Find the torrent in the database
        $torrent = Torrent::withAnyStatus()->findOrFail($id);
        // Grab Current User
        $user = Auth::user();
        // User's ratio is too low
        if ($user-&gt;getRatio() &lt; config('other.ratio')) {
            return Redirect::route('torrent', ['slug' =&gt; $torrent-&gt;slug, 'id' =&gt; $torrent-&gt;id])-&gt;with(Toastr::warning('Your Ratio Is To Low To Download!!!', 'Error!', ['options']));
        }

        // User's download rights are revoked
        if ($user-&gt;can_download == 0) {
            return Redirect::route('torrent', ['slug' =&gt; $torrent-&gt;slug, 'id' =&gt; $torrent-&gt;id])-&gt;with(Toastr::warning('Your Download Rights Have Been Revoked!!!', 'Error!', ['options']));
        }

        // Torrent Status Is Rejected
        if ($torrent-&gt;isRejected()) {
            return Redirect::route('torrent', ['slug' =&gt; $torrent-&gt;slug, 'id' =&gt; $torrent-&gt;id])-&gt;with(Toastr::warning('This Torrent Has Been Rejected By Staff', 'Error!', ['options']));
        }

    // Define the filename for the download
    $tmpFileName = $torrent-&gt;slug . '.torrent';

    // The torrent file exist ?
    if (!file_exists(getcwd() . '/files/torrents/' . $torrent-&gt;file_name)) {
        return Redirect::route('torrent', ['slug' =&gt; $torrent-&gt;slug, 'id' =&gt; $torrent-&gt;id])
        -&gt;with(Toastr::warning('Torrent File Not Found! Please Report This Torrent!', 'Error!', ['options']));
    } else {
        // Delete the last torrent tmp file
        if (file_exists(getcwd() . '/files/tmp/' . $tmpFileName)) {
            unlink(getcwd() . '/files/tmp/' . $tmpFileName);
        }
    }
    // Get the content of the torrent
    $dict = Bencode::bdecode(file_get_contents(getcwd() . '/files/torrents/' . $torrent-&gt;file_name));
    if (Auth::check()) {
        // Set the announce key and add the user passkey
            $dict['announce'] = route('announce', ['passkey' =&gt; $user-&gt;passkey]);
            // Remove Other announce url
            unset($dict['announce-list']);
    } else {
        return redirect('/login');
    }

    $fileToDownload = Bencode::bencode($dict);
    file_put_contents(getcwd() . '/files/tmp/' . $tmpFileName, $fileToDownload);
    return Response::download(getcwd() . '/files/tmp/' . $tmpFileName);
}</code></pre>

Include php5.6 and php7.0 versions in travis-ci verification

The package is configured with:

"require": {
     "php": "> = 5.6",
     "illuminate/support": "5.3.x | 5.4.x | 5.5.x"
   },

The tests should be run on those versions.

I did not have time to set up the environment and run the tests in php5.6 ...

Does this package minify html automatically?

i just installed this package in my laravel 5.5 application, and i dont know how to use it since it says in the documentation that for laravel 5.5 user, we just install and thats it. but my html is not getting minified, so am wondering if there is something i should do, any help will be highly appreciated.

Issue with select dropdown based on another dropdown

Hi,
I use Jquery to make select dropdown based on another dropdown, and it was working fine , when I use this package it select dropdown based on another dropdown not working anymore . do you know why ?

Many Thanks

DIV got display:none property and creates empty block

I am working on a website where the layout should be like https://screenshots.firefox.com/YYzwFg38q6apYAYy/transcom-website.dev. I installed this package and deployed to the server then the layout became this, https://screenshots.firefox.com/P4MTssYtBxe0wu6H/website.tclwebapps.com

I created a hexagon honeycomb using a jquery library. that library block became hidden. screenshot-2017-12-4 transcom ltd

I found a CSS block like the following before the </head> tag.

.page_speed_870855388{ display:none; } .page_speed_1687209754{ text-align: center; } .page_speed_1235677147{ padding-bottom:50px; }

Your environment

Include as many relevant details about the environment you experienced the bug in and how to reproduce it.

Skipping a route group not working

Detailed description

I have routes not being skipped when it's prefixed with admin in a route group.

An example of the url is http://example.com/admin/dashboard

I have the following in the laravel-page-speed config

'skip' => [
        '*/admin/*',
        ...

Your environment

Include as many relevant details about the environment you experienced the bug in and how to reproduce it.

PHP 7.1 Laravel 5.5

FatalThrowableError ?

Call to a member function getContent() on null {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to a member function getContent() on null at /app/vendor/renatomarinho/laravel-page-speed/src/Middleware/PageSpeed.php:33)

trimurls causes Pusher exception

When using the TrimUrls middleware (tested on its own with all others disabled)

Connections to Pusher are broken

This error is shown

app.js?id=dkjsdflkjsdf:55485 Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Invalid signature: Expected HMAC SHA256 hex digest of 5601.2191940:presence-chatroom.2:{\"user_id\":205,\"user_
 ...

Inline css background image, always change to page_speed_xxxx

im generate thumbnail image from youtube

var content = '<div id="player_' + newId() + '" class="video-player"></div>' + '<div class="video-info">' + '<button class="video-play-button"><i class="fa fa-play-circle"></i></button>' + '<div class="caption-content"><div class="container custom-container-padding"><div class="row container-header">' + '<div class="col-md-12"><p class="truncate-2">'+ caption +'</p></div></div></div></div>' + '<div class="video-thumb" style="background-image: url(' + url + ');"></div>' + '</div>'; $this.html(content);

but when i enable the laravel page speed, the thumbnail change to this <div class="video-thumb page_speed_809782230"></div>

this is my middleware protected $middleware = [ \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \App\Http\Middleware\MaintenanceMiddleware::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \RenatoMarinho\LaravelPageSpeed\Middleware\InlineCss::class, \RenatoMarinho\LaravelPageSpeed\Middleware\ElideAttributes::class, \RenatoMarinho\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class, \RenatoMarinho\LaravelPageSpeed\Middleware\RemoveComments::class, \RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class, \RenatoMarinho\LaravelPageSpeed\Middleware\RemoveQuotes::class, \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class,

sorry for my bad english

small bug with InsertDNSPrefetch

This one may not be breaking anything but I thought I would report it anyway

It's really quite weird

I have this in my html

<script>window.app_url = 'https://develop.mydomain.com';window.config = {"pusher":{"key":"xxx","cluster":"ap1"}};</script>

and the InsertDNSPrefetch turns the above into:

<link rel="dns-prefetch" href="//develop.mydomain.com';window.config">

Installation Issue

While installing this package i am getting this error

The use statement with non-compound name 'Config' has no effect

I am using Laravel 5.5 with latest update

A small TrimUrls bug

I add google embed map. Here is his code for example

<iframe src="https://www.google.ru/maps/embed/....."></iframe>

Then if trim_urls filter ON, he replace '/https:/' => '' and in browsers such as Firefox and Opera (in Chrome works fine ) i catch an error

The Google Maps API server rejected your request. Requests to this API must be over SSL. Load the API with "https://" instead of "http://".

To solve the problem, I think you should just avoid replacing URLs in the <iframe> :)

Text formatting within textarea

When using the collapse_whitespace filter, the content of a textarea (indenting) is lost.

This behaviour appears when editing a model that contains a TEXT field and that is displayed in a textarea form input on your views.

A quick fix for this is to disable the filter on your "edit" page, by adding a path in your skip routes of the laravel-page-speed.php config file:

'skip' => [ '*/edit', ...

Is there a way to disable whitespace collapsing only for a specific attribute of the DOM, like the textarea input?

PHP 7 syntax required

When i install it on Laravel 5.3 with PHP 5.6 i have this problem

FatalErrorException in PageSpeed.php line 26:
syntax error, unexpected ':', expecting ';' or '{'

This is a problem of PageSpeed that required a syntax of PHP 7

Bug in InlineCss Feature use URL

Error in css use url

My css is style="background-image: url('{{asset('assets/img/default-image/banner-bds.png')}}');"

This code throw a exception "preg_replace(): Unknown modifier '/'"

And i read exception message in whoop package "/style="background-image: url('//choviahe.dev/assets/img/default-image/banner-bds.png');"/" => "class="page_speed_237878972""

Enhancement: Increase internal performance with caching

For each added middleware, the isEnabled check is executed: https://github.com/renatomarinho/laravel-page-speed/blob/master/src/Middleware/PageSpeed.php#L58

Although the check itself isn't all that much:

$enable = config('laravel-page-speed.enable');
return (is_null($enable))?true: (boolean) $enable;

Having config called over and over won't do much good to the page speed itself.
It would be nice to store the result of config('laravel-page-speed.enable') in a static property of the abstract PageSpeed class like so:

abstract class PageSpeed
{
        private static $isEnabled;

        protected function isEnable()
        {
            if(!is_null(static::$isEnabled)){
                return static::$isEnabled;
            }
            $enable = config('laravel-page-speed.enable');
            return static::$isEnabled = (is_null($enable))?true: (boolean) $enable;
        }
    ...
}

written in github editor, so not PSR-2 compliant ;)

This way, each PageSpeed Middleware class can leverage from the same isEnabled property.

I know it's not a lot of performance gain. But since it's a rather easy addition I reckon it would be a nice small enhancement.

Disable the laravel page speed service is not working.

Detailed description

I set 'enable' => env('LARAVEL_PAGE_SPEED_ENABLE', false), to disable laravel page speed service. But its not working. I also set LARAVEL_PAGE_SPEED_ENABLE=false in .env file. But it also not working. How to disable Page Speed Service without commenting Page Speed Middlewares?

Development environment

  • Laravel v5.5
  • Version used (e.g. PHP 7.1):
  • Operating system and version (e.g. Windows 10):

Vue Component is not working when using this package

When I use this package, my Vue Components are not working.

Detailed description

It compresses the HTML code but the Vue components are not working. I use ajax request and fetch data to a single file Vue Component. Then I used it on blade page. Everything is working, but when I use this package to compress the code, the Vue component can't read the properties.

It's a bug

Your environment

I'm using Windows and Wamp server latest version.

  • Version used (e.g. PHP 7.1, HHVM 3): PHP 7.1, Laravel 5.5
  • Operating system and version (e.g. Ubuntu 16.04, Windows 7): Windows 10

Issue with inline script comment & laravel-debugbar package conflicts

Detailed description

In my application, sometimes I have a script in HTML:

<script>
// I need to comment what I want to do here
console.log('something here');
</script>

Then it throws an error Uncaught SyntaxError: Unexpected end of input

Context

I think many people will get this bug when using your package in their apps.

Possible implementation

Remove script comment in HTML

Your environment

  • PHP version: 7.1
  • Laravel 5.5

ErrorException PageSpeed.php

Just installed this package in one of my bigger projects to speed up the site.

But right after including, I get this error:

(1/1) ErrorExceptionpreg_replace(): Unknown modifier '/'

in PageSpeed.php (line 48)

(And here the whole html is getting spit out)

Compatibility with tightenco/ziggy

Hello, First of all, really like this package! But i was wondering if anyone has successfully combined this package with tightenco/ziggy. When i use it i get 2 errors at the moment:

Uncaught SyntaxError: Unexpected end of input
Uncaught ReferenceError: route is not defined (When i call the route function from another script)

Is it an idea to add a blade directive so i can skip certain parts from minification?

js errors after minification

Laravel 5.4 Vue.js

Clear installation of LPS package. Now we have errors:

Uncaught SyntaxError: Unexpected end of input
Uncaught SyntaxError: Invalid or unexpected token
Uncaught ReferenceError: PhpDebugBar is not defined
    at search:4
(anonymous) @ search:4
app.js:sourcemap:4572 jQuery.Deferred exception: $ is not a function TypeError: $ is not a function
Uncaught TypeError: $ is not a function
  • PhP 7.1
  • Windows 10 Pro
  • Vagrant - Homestead
  • local project

[pt_BR] - CollapseWhitespace quebrando dropzone.js

Primeiramente parabéns pelo trabalho Renato, acompanho desde quando o projeto tinha 15 estrelas rsrs. Cheque a compatibilidade do CollapseWhitespace com o plugin dropzone, pois ele não funciona após a aplicação desse middleware, com o erro "Unexpected end of script".

Mais especificamente, a regra

"/\n/" => '',

que está afetando o dropzone.js.

  • Php 7.1.10
  • Laravel 5.5
  • local

[Suggestion] - Issue with shouldProcessPageSpeed getting called for each Middleware

Detailed description

The shouldProcessPageSpeed on the base PageSpeed middleware is getting called for each middleware, essentially doing the check for each enabled feature. Now, this would make sense if the config would allow specific middleware to be skipped for some configured route patterns, but it doesn't.

Context

Running the pattern check for each middleware sounds expensive the more patterns and page speed features you add to a page request. Reducing the many regex checks will greatly reduce the page load speeds under heavy load.

I can provide a PR if this change is wanted.

Possible implementation

This issue proposes introducing a static field that keeps track of whether or not any previous request has passed or not (null = no previous check, true = pass, false = fail).

Your environment

  • Homestead on Mac OS Sierra

The package breaks the Laravel assertViewHas test method

I've been having a problem for some hours with the Laravel built-in assertViewHas test method when I pass a piece of data to a view and I concluded this package is the reason, the assertViewHas method was returning the message The response is not a view. so I decided make a little test in a new empty project and see the results, this is what I did.

First of all I installed Laravel and the package:

composer create-project --prefer-dist laravel/laravel example
...
composer require renatomarinho/laravel-page-speed

HomeTest.php

<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class HomeTest extends TestCase
{
    public function test_data_can_be_passed_to_a_view()
    {
        $response = $this->get('/');
        $response->assertStatus(200);
        $response->assertSeeText('Example page');
        $response->assertViewHas('data');
    }
}

web.php

<?php

Route::get('/', 'HomeController');

example.blade.php

<h1>Example page</h1>

HomeController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function __invoke()
    {
        return view('example', ['data' => 'A random piece of data']);
    }
}

At this point if I run the command vendor/bin/phpunit --filter=test_data_can_be_passed_to_a_view everything is fine


.                                                                   1 / 1 (100%)

Time: 958 ms, Memory: 14.00MB

OK (1 test, 3 assertions)

But if I add the package middlewares to the Kernel.php file...

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \App\Http\Middleware\TrustProxies::class,

        \RenatoMarinho\LaravelPageSpeed\Middleware\InlineCss::class,
        \RenatoMarinho\LaravelPageSpeed\Middleware\ElideAttributes::class,
        \RenatoMarinho\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class,
        \RenatoMarinho\LaravelPageSpeed\Middleware\RemoveComments::class,
        \RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,
        \RenatoMarinho\LaravelPageSpeed\Middleware\RemoveQuotes::class,
        \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class,
    ];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    ];
}

The output of the vendor/bin/phpunit --filter=test_data_can_be_passed_to_a_view is the following:

PHPUnit 6.5.5 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 867 ms, Memory: 14.00MB

There was 1 failure:

1) Tests\Feature\HomeTest::test_data_can_be_passed_to_a_view
The response is not a view.

C:\Users\Maxal\Desktop\example\vendor\laravel\framework\src\Illuminate\Foundation\Testing\TestResponse.php:613
C:\Users\Maxal\Desktop\example\vendor\laravel\framework\src\Illuminate\Foundation\Testing\TestResponse.php:558
C:\Users\Maxal\Desktop\example\tests\Feature\HomeTest.php:16

FAILURES!
Tests: 1, Assertions: 3, Failures: 1

I don't why this happens but it's happening!

I hope you will can reproduce the error, I will try to clone the repo and find the problem, for the moment I hope this help you. Greetings!

Inline SVG files are broken

This package is removing trailing slashes from HTML elements (e.g. XHTML syntax of an image: <img src="..." />) which is fine and correct for me.

But if you're using inline SVG files the package is also removing the trailing slashes from their child elements – but they are necessary to show the SVG file correctly.

Example

Facebook icon: shown correctly because there is only one path.

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 25 25" xml:space="preserve"><path d="M21.631,0H3.369C1.508,0,0,1.508,0,3.369v18.263C0,23.492,1.508,25,3.369,25h9.007l0.016-8.934H10.07 c-0.301,0-0.546-0.244-0.548-0.545l-0.011-2.88c-0.001-0.303,0.244-0.55,0.548-0.55h2.317V9.309c0-3.229,1.972-4.987,4.853-4.987 h2.364c0.302,0,0.548,0.245,0.548,0.548v2.428c0,0.302-0.245,0.547-0.547,0.548l-1.451,0c-1.566,0-1.87,0.745-1.87,1.837v2.409 h3.442c0.328,0,0.582,0.286,0.544,0.612l-0.341,2.88c-0.032,0.276-0.266,0.483-0.544,0.483h-3.086L16.272,25h5.359 C23.492,25,25,23.492,25,21.631V3.369C25,1.508,23.492,0,21.631,0z"/></svg>

Instagram icon: shown not correctly because there is more than one path.

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 25 25" xml:space="preserve"><path d="M18.101,0H6.899C3.095,0,0,3.095,0,6.899v11.202C0,21.905,3.095,25,6.899,25h11.202 C21.905,25,25,21.905,25,18.101V6.899C25,3.095,21.905,0,18.101,0z M22.782,18.101c0,2.581-2.1,4.681-4.681,4.681H6.899 c-2.581,0-4.681-2.1-4.681-4.681V6.899c0-2.581,2.1-4.681,4.681-4.681h11.202c2.581,0,4.681,2.1,4.681,4.681L22.782,18.101 L22.782,18.101z"/><path d="M12.5,6.059c-3.552,0-6.442,2.89-6.442,6.442s2.89,6.442,6.442,6.442c3.552,0,6.442-2.89,6.442-6.442 S16.052,6.059,12.5,6.059z M12.5,16.724c-2.329,0-4.224-1.895-4.224-4.223c0-2.329,1.895-4.224,4.224-4.224 c2.329,0,4.224,1.895,4.224,4.224C16.724,14.829,14.829,16.724,12.5,16.724z"/><path d="M19.212,4.178c-0.427,0-0.847,0.173-1.149,0.476c-0.303,0.302-0.478,0.722-0.478,1.151 c0,0.427,0.175,0.847,0.478,1.15c0.302,0.302,0.722,0.476,1.149,0.476c0.429,0,0.847-0.175,1.15-0.476 c0.303-0.303,0.476-0.723,0.476-1.15c0-0.429-0.173-0.849-0.476-1.151C20.061,4.351,19.641,4.178,19.212,4.178z"/></svg>

Tested in (latest version each)

  • Chrome
  • Firefox
  • Safari
  • Opera

problem in illuminate/support": "5.3.* || 5.4.* || 5.5.* || 5.6.*"

I've been using that way on #69 by adding "illuminate/support": "5.3.* || 5.4.* || 5.5.* || 5.6.*", result, there is a problem ?

Problem 1

  • Conclusion: don't install illuminate/support v5.5.34
  • Conclusion: don't install illuminate/support v5.5.33
  • Conclusion: don't install illuminate/support v5.5.28
  • Conclusion: don't install illuminate/support v5.5.17
  • Conclusion: don't install illuminate/support v5.5.16
  • Conclusion: don't install illuminate/support v5.5.2
  • Conclusion: don't install illuminate/support v5.5.0
  • Conclusion: don't install illuminate/support v5.4.36
  • Conclusion: don't install illuminate/support v5.4.27
  • Conclusion: don't install illuminate/support v5.4.19
  • Conclusion: don't install illuminate/support v5.4.17
  • Conclusion: don't install illuminate/support v5.4.13
  • Conclusion: don't install illuminate/support v5.4.9
  • Conclusion: don't install illuminate/support v5.4.0
  • Conclusion: don't install illuminate/support v5.3.23
  • Conclusion: don't install illuminate/support v5.3.16
  • Conclusion: don't install illuminate/support v5.3.4
  • Installation request for laravel/framework 5.6.* -> satisfiable by laravel/framework[v5.6.0, v5.6.1, v5.6.2, v5.6.3].
  • Installation request for laravel/framework (locked at v5.6.3, required as 5.6.) -> satisfiable by laravel/framework[v5.6.3].
  • Installation request for codecasts/laravel-jwt ^0.9.0 -> satisfiable by codecasts/laravel-jwt[0.9.0].
  • renatomarinho/laravel-page-speed 1.8.0 requires illuminate/support 5.3. || 5.4.* || 5.5.* -> satisfiable by illuminate/support[v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34].
  • renatomarinho/laravel-page-speed 1.8.1 requires illuminate/support 5.3.* || 5.4.* || 5.5.* -> satisfiable by illuminate/support[v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34].
  • renatomarinho/laravel-page-speed 1.8.2 requires illuminate/support 5.3.* || 5.4.* || 5.5.* -> satisfiable by illuminate/support[v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34].
  • renatomarinho/laravel-page-speed 1.8.3 requires illuminate/support 5.3.* || 5.4.* || 5.5.* -> satisfiable by illuminate/support[v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34].
  • renatomarinho/laravel-page-speed 1.8.4 requires illuminate/support 5.3.* || 5.4.* || 5.5.* -> satisfiable by illuminate/support[v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34].
  • renatomarinho/laravel-page-speed 1.8.5 requires illuminate/support 5.3.* || 5.4.* || 5.5.* -> satisfiable by illuminate/support[v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34].
  • renatomarinho/laravel-page-speed 1.8.6 requires illuminate/support 5.3.* || 5.4.* || 5.5.* -> satisfiable by illuminate/support[v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34].
  • Conclusion: don't install illuminate/support v5.3.0
  • Installation request for renatomarinho/laravel-page-speed ^1.8 -> satisfiable by renatomarinho/laravel-page-speed[1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6].

RemoveQuotes issues

when using //\RenatoMarinho\LaravelPageSpeed\Middleware\RemoveQuotes::class, it is breaking my image urls. For instance:

            <button type="submit" value="10" name="tip" class="btn"><img src="/images/10coin.png"/></button>
            <button type="submit" value="20" name="tip" class="btn"><img src="/images/20coin.png"/></button>
            <button type="submit" value="50" name="tip" class="btn"><img src="/images/50coin.png"/></button>
            <button type="submit" value="100" name="tip" class="btn"><img src="/images/100coin.png"/></button>
            <button type="submit" value="200" name="tip" class="btn"><img src="/images/200coin.png"/></button>
            <button type="submit" value="500" name="tip" class="btn"><img src="/images/500coin.png"/></button>
            <button type="submit" value="1000" name="tip" class="btn"><img src="/images/1000coin.png"/></button>

Urls go from https://myurl.com/images/50coin.png <---works

TO

https://myurl.com/images/50coin.png/ <---broken with added /

collapse_whitespace issues

collapse_whitespace breaks some css and https://github.com/wbb/WysiBB

collapse_whitespace is breaking some of my css. more so I think the html layout. also seems to break WysiBB editor. More so the JS part that is needed to apply WysiBB to a text area.

is collapse_whitespace that beneficial? or should I just disable it?

Removes whitespaces from textboxes

It seems that the RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace middleware trims whitespaces from inside a <textarea></textarea> input.

Detailed description

Lets say you have a textbox with the following:

<?php
    echo "Hello world!";
?>

comes out as

<?phpecho "Hello world!";?>

This seems like an issue for me, maybe it could become possible to disable this for textarea's?

Context

For example when having a textarea where you want the output to be formatted correctly, like my PHP example from above.

Your environment

  • PHP v7.1.8
  • MacOS Sierra v10.12.6
  • Package v1.8.1

Should it be compressed when responding directly to a binary file?

When the line responds directly to the compression of the picture, the picture will be damaged,Especially the direct output picture in the verification code package is used, and this leads to the verification code error. when the response when the binary stream should not be compressed

TrimUrls is removing necessary information for JSON-LD

This class remove the URL scheme from everywhere.

\RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,

This renders the JSON-LD object invalid and stop Google from properly indexing your rich snippets.

<script type="application/ld+json">
{  
   "@context":"http://schema.org",
   "thumbnailUrl":"http://sampleurl"
}
</script>

Become this:

<script type="application/ld+json">
{  
   "@context":"//schema.org",
   "thumbnailUrl":"//sampleurl"
}
</script>

It should automatically exclude these parts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.