WP Manifestindependent plugin directory
manifest / performance / wee-conditional-loader

wee Conditional Loader GitLab

A conditional CSS and JavaScript loader for WordPress. It can be used to load files only if a certain CSS class or ID is present on a page.

by Walter Ebert · gitlab.com/walterebert/wee-conditional-loader · website

0stars
11composer installs
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://gitlab.com/walterebert/wee-conditional-loader/-/archive/master/wee-conditional-loader-master.zip

Also on Packagist as wee/conditional-loader:

composer require wee/conditional-loader

From the readme

wee Conditional Loader A conditional CSS and JavaScript loader for WordPress. It can be used to load files only if a certain CSS class or ID is present on a page. It uses Filament Group's loadCSS and loadJS. Warning: Execution order of requested scripts is not managed, so you should not use it to load multiple javascript files that depend on one another. JavaScript files will be loaded when the DOM is ready. Because of this, your scripts should not contain: - document.addEventListener( 'DOMContentLoaded', callback ); - window.onload - jQuery(document).ready(...) Example of loading JavaScript for a plugin only if the plugin CSS class is present: Example of loading CSS for a plugin only if the plugin ID is present: Of course you can also use it in themes: The JavaScript for this plugin is loaded inline by default and as external files if you are running HTTP/2.0. You can explicitly tell WordPress to use external files by setting the following constant in wp-config.php: This plugin can also be used to load CSS files asynchronously: Author Walter Ebert License MIT

Read the full README on GitLab →