✨ Up to
-70%
on the 1st year
Days
Hours
Minutes
Seconds

Head Sorter - Intelligent reorganization of the <head> to boost speed and SEO

For many WordPress sites, the order of tags in the <head> is silent chaos: metadata drowns out, CSS arrives too late, scripts block... The result: slower rendering, lower Web Vitals metrics and poorer SEO. The module Head Sorter from WPMasterToolKit has been created to put things in order automatically - without complicated settings - and put what really matters first.

Which plug-in can the "Head Sorter" module replace?

In many cases, Head Sorter can replace small plugins dedicated to "head tag sorting", load order optimizations, or in-house snippets that attempt to manually move <meta>, <link> and <script>. Here, everything is managed systematically and securely via an HTML parser.

Discover the module :
Free

How it works (in plain English)

  1. Intercepting front-end rendering
    The module attaches to template_redirect (priority -1000) to start a output buffer (output buffering). It does not that the Front-end.
  2. HTML detection
    If the page does not contain </html>the content remains unchanged.
  3. Analysis of <head> with DOMDocument
    The contents of the <head> is loaded into a DOMDocument (with silent error handling), then all child tags are evaluated and sorted according to a weight.
  4. Sort by importance
    Nodes (tags, text, comments) are assigned a weight. We re-inserts then the elements in the <head> from most to least important, in preserving comments and texts.

The priority grid (from most to least important)

  • META (10) : charset, viewportand some http-equiv reviews (content-security-policy, content-type, default-styleetc.)
  • TITLE (9)
  • PRECONNECT (8) : <link rel="preconnect">
  • ASYNC_SCRIPT (7) : <script src ... async>
  • IMPORT_STYLES (6) : <style> containing @import
  • SYNC_SCRIPT (5) : <script> inline blocking (non deferno asyncno type="module"and no type JSON)
  • SYNC_STYLES (4) : <link rel="stylesheet"> and <style>
  • PRELOAD (3) : <link rel="preload|modulepreload">
  • DEFER_SCRIPT (2) : <script src ... defer> or <script type="module"> (without async)
  • PREFETCH_PRERENDER (1) : <link rel="prefetch|dns-prefetch|prerender">
  • OTHER (0): everything else, including JSON scripts (application/ld+jsonetc.) and non-element nodes (texts, comments), which are kept

👉 In concrete terms, your critical tags (charset, viewport, title) go to the topresources, followed by connection and CSS necessary for rendering, and blocking scripts are eliminated as far as possible by giving priority to async/defer/module.

Discover the module :
Free

Why it's good for performance and SEO

  • Faster FCP/LCP essential meta and styles arrive early, reducing initial rendering time.
  • Less blocking JS scripts async/defer/module are favored, reducing the impact on the critical rendering path.
  • Technical SEO one <head> better structured helps engines to understand and index correctly (consistent title/meta first).

Behaviors and compatibility to know

  • Front-end only : hooked on template_redirect. The admin is not impacted.
  • Content preservation comments and texts in the <head> are retained.
  • JSON scripts (e.g. application/ld+json) : not treated as blocking scripts ("OTHER" weight) to avoid moving them aggressively.
  • ES modules (type="module"): treated as defer by default (good for rendering).
  • Ill-formed HTML DOMDocument can attempt to "correct" a badly structured head, but keep HTML clean for best results.

How to use this module

  1. Activate the Head Sorter module in WPMasterToolKit.
  2. Empty cache your plugins/server/CDN if you use them.
  3. Control a page (home page, sample article) to check the order of the <head> with the browser's dev tools.
  4. No adjustments to make: everything is automatic.

Our technical choices (and why)

  • Output buffering at the earliest (template_redirectpriority -1000) to capture the final rendering of the page without touching the heart of WordPress or the themes.
  • DOMDocument for a reliable handling rather than fragile regexes.
  • Weight matrix clear and extensible code to prioritize :
    • Meta/title first and foremost (web standards + SEO).
    • Preconnect/Preload/Style sheets before blocking scripts.
    • async/defer/module better off than conventional synchronous scripts.
  • Conservatism on JSON : exclusion of type containing json from the "synchronous script" category to avoid affecting the markup of structured data.

Hooks and filters

This module exposes no apply_filters or do_action personalized. Behavior is entirely internal.

Practical tips

  • Avoid @import in your <style> : even if they have priority here, they remain slower that a <link rel="stylesheet">.
  • If a critical script needs to run early, prefer defer (or type="module") rather than synchronous, so as not to block rendering.
  • Use rel="preconnect" and rel="preload" with parsimony and precision (preload only what is critical).
Pro
1 site
3.50$
/Month
14
Days
Money-back guarantee
risk-free at 100 %!

Conclusion

The module Head Sorter brings order to the <head> of your WordPress site automatically, respecting good performance and technical SEO practices. Activate it, clear your caches, and enjoy cleaner, faster loading - without wasting time micromanaging tags.