Git Product home page Git Product logo

Comments (7)

er1z avatar er1z commented on May 20, 2024 3

I know how the gzipping output works. The matter is how do you trigger gzipping within Twig because this is what is everything about question.

Twig has no option on this because it's only templating engine, not a response handler.

from symfony-pack.

20uf avatar 20uf commented on May 20, 2024 1

Hello,

I invite you to make a PR with your different proposals.

Have a good day :)

from symfony-pack.

jockhip12 avatar jockhip12 commented on May 20, 2024

Hello @tinnerdxp,

Thank you for your comment and I think also that some responses should be improved.
But for your first example, I think that you are wrong according to the Symfony documentation:

This tag (spaceless) is not meant to "optimize" the size of the generated HTML content but merely to avoid extra whitespace between HTML tags to avoid browser rendering quirks under some circumstances.

If you want to optimize the size of the generated HTML content, gzip compress the output instead

For more information: https://twig.symfony.com/doc/2.x/filters/spaceless.html

Cheers

from symfony-pack.

er1z avatar er1z commented on May 20, 2024

@jockhip12 — yeah, but how the Twig could compress output itself?

from symfony-pack.

jockhip12 avatar jockhip12 commented on May 20, 2024

@jockhip12 — yeah, but how the Twig could compress output itself?

I didn't get your question, but you can find more details here :
https://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

from symfony-pack.

jockhip12 avatar jockhip12 commented on May 20, 2024

The matter is how do you trigger gzipping within Twig

I got your point, and honestly I don't have an answer :/

from symfony-pack.

JuGid avatar JuGid commented on May 20, 2024

I would like to add an answer that might be wrong in controller.yml. That's a small contribution, but hope it helps as well.

question: 'Which of these response objects does not exists?'
        answers:
            - {value: XmlResponse,        correct: true}
            - {value: FileResponse,        correct: true}
            - {value: TwigResponse,        correct: true}
            - {value: JsonResponse,       correct: false}
            - {value: BinaryFileResponse, correct: false}
            - {value: RedirectResponse,   correct: false}
            - {value: StreamedResponse,   correct: false}
        help: |
            'https://symfony.com/doc/current/components/http_foundation.html#response'

From the documentation of the v5.3, this JsonResponse exists : https://symfony.com/doc/current/components/http_foundation.html#creating-a-json-response

from symfony-pack.

Related Issues (13)

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.