Skip to content

Adding details about "defer" and legacy jquery #15280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions frontend/encore/legacy-applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,18 @@ The ``global`` variable is a special way of setting things in the ``window``
variable. In a web context, using ``global`` and ``window`` are equivalent,
except that ``window.jQuery`` won't work when using ``autoProvidejQuery()``.
In other words, use ``global``.

Additionally, be sure to set the ``script_attributes.defer`` option to ``false``
in your ``webpack_encore.yaml`` file:

.. code-block:: yaml

# config/packages/webpack_encore.yaml
webpack_encore:
script_attributes:
defer: false

This will make sure there is *not* a ``defer`` attribute on your ``script``
tags. For more information, see `Moving <script> inside <head> and the "defer" Attribute`_

.. _`Moving <script> inside <head> and the "defer" Attribute`: https://symfony.com/blog/moving-script-inside-head-and-the-defer-attribute