Assets
- Plugin page: https://plogins.com/plogins-assets/
- Documentation: https://plogins.com/plogins-assets/docs/
- Author: WPPoland.com
- WordPress.org contributor: motylanogha
- Source: https://github.com/wppoland/plogins-assets
Assets removes specific scripts and styles from the pages where they are not needed. Most plugins enqueue their CSS and JavaScript on every page, even where the feature never appears, and that weight slows every visit. Assets uses the standard WordPress enqueue system (wp_dequeue_script / wp_dequeue_style), so there is nothing proprietary to learn and no page-builder lock-in. It works on any theme and does not require WooCommerce.
How it works
Section titled “How it works”For each rule you add, Assets checks the current front-end request and, when the rule’s condition matches, dequeues and deregisters the handle so it is not printed. Rules run on wp_enqueue_scripts at a late priority (after themes and plugins have enqueued), and never run in the admin.
Adding a rule
Section titled “Adding a rule”Open the Plogins Assets menu and add a rule with:
- Handle - the registered name of the script or style to remove (e.g.
contact-form-7). The field autocompletes from the handles registered on your site. - Type - script (JS) or style (CSS).
- Remove when - the condition that decides where the handle is removed.
- Post/Page IDs - optional, only used by the single-post conditions.
Conditions
Section titled “Conditions”- Everywhere - every front-end page.
- On the front page - the site front page.
- On the blog posts index - the posts index.
- On single posts/pages (matching IDs) - single posts or pages; limit to specific IDs, or leave IDs empty to match any single.
- Except single posts/pages (matching IDs) - the inverse.
- On mobile devices / On desktop devices - by
wp_is_mobile().
Finding a handle name
Section titled “Finding a handle name”Open the page in your browser, view source or the Network tab, and look at the id attribute of the <script> / <link> tags - it usually ends in -js or -css (the handle is that value without the suffix). The settings screen also offers autocomplete from the handles currently registered on your site.
A note on dependencies
Section titled “A note on dependencies”Assets removes only what you configure. If a handle you remove is a dependency of another script, that other script may stop working. Change one rule at a time and verify the front end. Removing a rule restores the asset instantly.