add defer attribute to script tags for improved loading performance#3750
add defer attribute to script tags for improved loading performance#3750RynoCODE wants to merge 1 commit intopi-hole:developmentfrom
Conversation
Signed-off-by: RynoCODE <74398242+RynoCODE@users.noreply.github.com>
|
Thanks for your contribution. We had a PR adding |
|
Thank you for providing that context. After reviewing the project history, specifically Issue #3302 and PR #3382, which reverted the initial attempt in PR #3295, the root cause of the issue is clear. The TypeErrors arise because the defer attribute delays script execution until the DOM finishes parsing. Currently, the project's JavaScript files are distributed across various .lp view templates rather than being centralized. As a result, introducing defer disrupts the execution sequence for critical dependencies like jQuery, which must load synchronously to support these fragmented templates. I think the scattered js needs to be centralised which will also help in long term development. |
Thank you for your contribution to the Pi-hole Community!
Please read the comments below to help us consider your Pull Request.
We are all volunteers and completing the process outlined will help us review your commits quicker.
Please make sure you
What does this PR aim to accomplish?:
PR aims to improve the page load performance and rendering speed of the Pi-hole web interface by ensuring non-critical scripts do not block the initial HTML parsing.
How does this PR accomplish the above?:
Added the defer attribute to <script> tags across the HTML/PHP templates. This allows the browser to continue parsing the DOM while the JavaScript files are being downloaded in the background, executing them only after the document has been fully parsed. This increases the speed for render load.
Link documentation PRs if any are needed to support this PR:
NA
By submitting this pull request, I confirm the following:
git rebase)