Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#43373 new enhancement

Evaluate Async & Defer for Inline WordPress Admin Scripts

Reported by: bhubbard Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: close
Focuses: javascript, administration, performance Cc:


There are many places within WordPress core where script tags are called inline. I think WordPress performance could benefit greatly if these were reviewed to see if adding async="async" or defer="defer" could improve performance. Here are some files and lines examples:

about.php L316
admin-footer.php L110
admin-header.php L77, L198
media.php L253, L474, L573, plus more

Not really a full test, but I ran a quick install and did a global find and replace within for the following:

<script type="text/javascript">
<script type="text/javascript" async="async">

I saw some decent performance improvements, and no obvious broken issues.

Change History (2)

#1 @mihai2u
4 years ago

  • Keywords close added

Hi bhubbard,

You might've gotten a performance boost because your find/replace applied to external scripts as well.

In the specs, you can see that the async attribute is only for external scripts (and should only be used if the src attribute is present). Relevant link: https://www.w3schools.com/TAgs/att_script_async.asp

My suggestion is to close this ticket and focus instead on getting ticket #12009 moving forward in order to properly add support for deferring or asyncing external scripts in the Wordpress way.

#2 @pento
3 years ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.