Skip to content

Rules and conditions in Pagelean

This guide provides a comprehensive reference for Pagelean’s conditional targeting rules, dependency handling, and deregistration options.

When creating an asset rule, the Remove when dropdown determines where Pagelean applies wp_dequeue_script or wp_dequeue_style:

Condition Match logic Use case
Everywhere Matches all frontend requests (! is_admin()). Completely disable an obsolete plugin asset without deactivating the entire plugin.
On the front page Matches is_front_page(). Remove heavy sliders, blog widgets, or gallery assets from your homepage.
On the blog posts index Matches is_home(). Strip ecommerce or portfolio scripts from the blog feed.
On single posts/pages (matching IDs) Matches is_singular() matching the specified post/page IDs. If IDs are left blank, matches all singular views. Remove builder scripts or heavy media libraries from specific articles.
Except single posts/pages (matching IDs) Inverts the match: unloads everywhere except on the specified post or page IDs. Essential for contact forms (e.g., Contact Form 7, WPForms) or booking calendars needed on only 1 or 2 landing pages.
On mobile devices Matches wp_is_mobile(). Remove desktop-only hover effects, cursor scripts, or full-width carousels on mobile screens.
On desktop devices Matches ! wp_is_mobile(). Unload mobile-specific navigation scripts on desktop browsers.
On single entries of a post type Matches is_singular($post_type) for the chosen custom post type. Unload store scripts across documentation articles or custom portfolio post types.
On the WooCommerce shop page Matches is_shop(). Strip single-product upsell or review assets from catalog archive views.
On WooCommerce product pages Matches is_product(). Remove general catalog scripts from individual product detail pages.
On the WooCommerce cart Matches is_cart(). Remove non-checkout related third-party analytics or widgets from the cart.
On the WooCommerce checkout Matches is_checkout() && ! is_order_received_page(). Strip social share buttons, review widgets, and unneeded scripts from the sensitive checkout funnel.

Note: WooCommerce conditions appear in the dropdown only when WooCommerce is active on your site.

Dequeue vs. Deregister: Understanding script dependencies

Section titled “Dequeue vs. Deregister: Understanding script dependencies”

WordPress manages scripts and styles as a dependency graph. When plugin A lists plugin B’s script as a dependency ($deps = ['plugin-b-handle']), WordPress automatically loads plugin B whenever plugin A is enqueued.

By default, Pagelean executes wp_dequeue_script($handle) and wp_dequeue_style($handle) at priority 100 on wp_enqueue_scripts.

  • This tells WordPress not to print the script in the HTML header or footer.
  • Dependency behavior: If another active script on the page explicitly lists the dequeued handle as a required dependency, WordPress will honor that dependency and still output the file.

When you check Also deregister on a Pagelean rule:

  • Pagelean executes wp_deregister_script($handle) and wp_deregister_style($handle).
  • This removes the handle entirely from WordPress’s registered asset registry ($wp_scripts or $wp_styles).
  • Dependency behavior: Even if other scripts depend on this handle, WordPress cannot load it. Any dependent script that strictly requires it may fail or produce a console error.
  • Best practice: Start with standard dequeue. Only check Also deregister if the file continues to load due to aggressive third-party dependencies, and verify in your browser console that dependent features are not broken.

Handles are the internal programmatic identifiers passed to wp_register_script() or wp_enqueue_style().

  1. Automatic suggestion: Browse your site logged in as an administrator. Pagelean records front-end script and style handles automatically. When adding a rule, start typing in the Handle input to view matching recorded assets.
  2. Browser DevTools inspection:
    • Open your browser’s Developer Tools (F12) and view the page source or DOM tree.
    • Locate the <script src="..."> or <link rel="stylesheet" href="..."> tag.
    • Look at the id attribute: WordPress appends -js to script IDs and -css to stylesheet IDs.
    • Example: An id of contact-form-7-css corresponds to the handle contact-form-7.
    • Example: An id of wc-cart-fragments-js corresponds to the handle wc-cart-fragments.